人人商城

news.php 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. if (!(defined('ES_PATH'))) {
  3. exit('Access Denied');
  4. }
  5. class NewsController extends Controller
  6. {
  7. public function index()
  8. {
  9. global $_W;
  10. global $_GPC;
  11. $pindex = max(1, intval($_GPC['page']));
  12. $psize = 10;
  13. $condition = ' and a.status = 1 ';
  14. $params = array();
  15. if (!(empty($_GPC['keyword']))) {
  16. $_GPC['keyword'] = trim($_GPC['keyword']);
  17. $condition .= ' and a.title like :keyword';
  18. $params[':keyword'] = '%' . $_GPC['keyword'] . '%';
  19. }
  20. if (!(empty($_GPC['cate']))) {
  21. $cateid = intval($_GPC['cate']);
  22. $condition .= ' and a.cate = :cate';
  23. $params[':cate'] = $cateid;
  24. }
  25. $articles = pdo_fetchall('SELECT a.* ,c.id as cid,c.name FROM ' . tablename('ewei_shop_system_company_article') . ' AS a' . "\n" . ' LEFT JOIN ' . tablename('ewei_shop_system_company_category') . ' AS c ON a.cate = c.id and c.status = 1' . "\n" . ' WHERE 1 ' . $condition . ' ORDER BY a.displayorder DESC LIMIT ' . (($pindex - 1) * $psize) . ',' . $psize, $params);
  26. $total = pdo_fetchcolumn('SELECT count(1) FROM ' . tablename('ewei_shop_system_company_article') . ' as a WHERE 1 ' . $condition, $params);
  27. $category = pdo_fetchall('select id,name from ' . tablename('ewei_shop_system_company_category') . ' where status = 1 order by displayorder asc ');
  28. $pager = $this->pagination($total, $pindex, $psize);
  29. $basicset = $this->basicset();
  30. $title = '新闻中心';
  31. include $this->template('news/index');
  32. }
  33. public function detail()
  34. {
  35. global $_W;
  36. global $_GPC;
  37. $id = intval($_GPC['id']);
  38. $article = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_system_company_article') . ' AS a' . "\n" . ' LEFT JOIN ' . tablename('ewei_shop_system_company_category') . ' AS c ON a.cate = c.id' . "\n" . ' WHERE a.id = ' . $id);
  39. $articles = pdo_fetchall('SELECT * FROM ' . tablename('ewei_shop_system_company_article') . ' AS a' . "\n" . ' WHERE a.status = 1 ORDER BY RAND() DESC LIMIT 4 ');
  40. $relevant_top = pdo_fetch('SELECT * FROM ' . tablename('ewei_shop_system_article') . ' AS a' . "\n" . ' WHERE a.status = 1 ORDER BY RAND()');
  41. $relevant = pdo_fetchall('SELECT * FROM ' . tablename('ewei_shop_system_article') . ' AS a' . "\n" . ' WHERE a.status = 1 ORDER BY RAND() DESC LIMIT 6 ');
  42. $basicset = $this->basicset();
  43. $title = $article['title'];
  44. include $this->template('news/detail');
  45. }
  46. }
  47. ?>