博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
thinkCMF----列表页跳转
阅读量:6881 次
发布时间:2019-06-27

本文共 2694 字,大约阅读时间需要 8 分钟。

thinkCMF列表循环有个:用来循环文章列表。

$where=[ 'post.create_time'=>['egt',0] ]; $page=[ 'list_rows'=>10, 'next'=>'下一页', 'prev'=>'上一页' ];

但是用这个,一直用不了,就自己重新写了一个:修改 ListController.class 类:

class ListController extends HomeBaseController{    public function index(){        $id = $this->request->param('id', 0, 'intval');                    $portalCategoryModel = new PortalCategoryModel();        $category = $portalCategoryModel->where('id', $id)->where('status', 1)->find();        // 获取当前栏目下的所有子栏目ID        $category_list = Db::name('portal_category')->field(array('id','parent_id'))->select();        $category_arr = array();        $cur_category_list = array();        array_push($cur_category_list,intval($id));        foreach($category_list as $v){            $arr = array();            $arr['id'] = $v['id'];            $arr['pid'] = $v['parent_id'];            array_push($category_arr,$arr);        }        //得到当前栏目所有的子栏目ids        $cur_category_ids = array_merge($cur_category_list,get_all_child($category_arr,$id));        //获取当前所有子栏目的所有文章ids        $all_post_ids_arr = array();        $all_post_ids = Db::name('portal_category_post')->where('category_id','in',$cur_category_ids)->field(array('post_id'))->select();        foreach($all_post_ids as $v){            array_push($all_post_ids_arr,$v['post_id']);        }                // 获取当前栏目及子栏目所有的文章列表        $where = array();        $where['id'] = array('in',$all_post_ids_arr);        $where['post_type'] = 1;        $where['post_status'] = 1;        $pagelist_arr = Db::name('portal_post')->where($where)->paginate(12);        $page = $pagelist_arr->render();        // 处理跳转链接 和 栏目的图片        $pagelist = array();        foreach($pagelist_arr as $k => $v){            $v['thumb'] = '/upload/'.json_decode($v['more'],true)['thumbnail'];            $v['category_id'] = $this->get_category_id($v['id']);            array_push($pagelist,$v);        }        $this->assign('pagelist',$pagelist);            $this->assign('category', $category);        $this->assign('page', $page);        $listTpl = empty($category['list_tpl']) ? 'list' : $category['list_tpl'];        return $this->fetch('/' . $listTpl);    }    /*     * get_category_id 根据文章的id 获取栏目 category_id     */    private function get_category_id($id){        $categoryinfo = Db::name('portal_category_post')->where('post_id','eq',$id)->field('category_id')->find();         return $categoryinfo['category_id'];    }}

具体使用:

 

转载于:https://www.cnblogs.com/e0yu/p/9540734.html

你可能感兴趣的文章
Ehcache(08)——可阻塞的Cache——BlockingCache
查看>>
使用maven镜像
查看>>
curl命令详解
查看>>
手机wifi密码的保存位置
查看>>
android L新控件RecyclerView详解与DeMo[转]
查看>>
Swift 委托/代理设计模式
查看>>
hdu 5587 Array 数学题
查看>>
EBS R12.2应用层启动脚本的执行过程
查看>>
timeSeries db之:使用Metrics监控应用程序的性能 (zz)
查看>>
File上传
查看>>
ssh文件传输命令:sz与rz命令
查看>>
Oracle 12c 添加scott用户
查看>>
Guid.NewGuid().ToString()得几种格式显示
查看>>
Eclipse迅速执行:Exception in thread "main" java.lang.OutOfMemoryError: Java heap space...
查看>>
[转].NET下读取PDF文本
查看>>
Window 10 :我的性能优化:那效果,杠杠的!
查看>>
hdu 3683 Gomoku (模拟、搜索)
查看>>
用curl抓取网站数据,仿造IP、防屏蔽终极强悍解决方式
查看>>
Loadrunner中参数化实战(7)-Unique+Each iteration
查看>>
POJ1659Frogs' Neighborhood(lavel定理)
查看>>