PageController.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2014 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: Dean <zxxjjforever@163.com>
  8. // +----------------------------------------------------------------------
  9. namespace app\appapi\controller;
  10. use cmf\controller\HomeBaseController;
  11. use think\facade\Db;
  12. use think\db\Query;
  13. class PageController extends HomebaseController{
  14. //文章
  15. public function news() {
  16. $id = $this->request->param('id',0,'intval');
  17. $news=Db::name("posts")
  18. ->field("post_title,post_content,post_title_en")
  19. ->where("id='{$id}'")->find();
  20. $language=cmf_current_lang();
  21. if($language=='en'){
  22. $news['post_title']=$news['post_title_en'];
  23. }
  24. $this->assign("news",$news);
  25. $this->assign('id',$id);
  26. return $this->fetch();
  27. }
  28. //读取常见问题下的文章列表
  29. public function questions(){
  30. $questionList=Db::name("posts")
  31. ->field("id,post_title,post_title_en")
  32. ->where("termid=13")
  33. ->select()
  34. ->toArray();
  35. //$questionList->all();
  36. $language=cmf_current_lang();
  37. foreach($questionList as $k=>$v){
  38. if($language=='en'){
  39. $questionList[$k]['post_title']=$v['post_title_en'];
  40. }
  41. }
  42. $time=time();
  43. $this->assign("questionList",$questionList);
  44. $this->assign("time",$time);
  45. return $this->fetch();
  46. }
  47. }