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

<php>
$where=[
'post.create_time'=>['egt',0]
];
$page=[
'list_rows'=>10,
'next'=>'下一页',
'prev'=>'上一页'
];
</php>
<portal:articles item="vo" where="$where" order="post.create_time DESC" page="$page" relation="categories" categoryIds="$category.id" returnVarName="articles_data">
</portal:articles>

但是用这个,一直用不了,就自己重新写了一个:修改 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'];
}
}

具体使用:

<foreach name="pagelist" item="v">
<dl class="caselist">
<dt class="ab"><a href="{:cmf_url('portal/Article/index',array('id'=>$v['id'],'cid'=>$v['category_id']))}"><img src="__ROOT__{$v['thumb']}" alt="" width="285" height="190"></a></dt>
<dd class="info">
<a href="{:cmf_url('portal/Article/index',array('id'=>$v['id'],'cid'=>$v['category_id']))}">{$v['post_title']}</a>
<a href="{:cmf_url('portal/Article/index',array('id'=>$v['id'],'cid'=>$v['category_id']))}">企业官网</a>
</dd>
</dl>
</foreach>
<div class="pagination tc">
{$page}
</div>

thinkCMF----列表页跳转的更多相关文章

  1. vue通过id从列表页跳转到对应的详情页

    1. 列表页:列表页带id跳转到详情页 详情页:把id传回到后台就可以获取到数据了 2.列表页跳转到详情页并更改详情页的标题 列表页:带id和页面标题的typeid跳转到详情页 详情页:在html绑定 ...

  2. VUE通过id从列表页跳转到相对的详情页

    新闻列表页面: 在这里我用a标签进行跳转,在vue里面可以这样写<router-link></router-link> 1 <router-link :to=" ...

  3. 夺命雷公狗ThinkPHP项目之----企业网站23之网站前台二级分类的跳转(URL跳转到列表页或产品页)

    我们现在开始做实现我们的二级菜单如何跳转到指定的列表页或者产品也呢?? 我们分享下数据库情况: 我们的数据库里提前给我们预留了一个cate_type的字段,那么我们可以让这个字段进行判断,从而遍历出指 ...

  4. 微信小程序页面列表与详情页跳转的正确姿势

    初学小程序,碰到列表与详情页跳转遇到的问题,记录一下. 一.问题 1个列表页: 1个详情页: 列表页代码: onLoad:异步查询数据并setData 详情页代码: 保存成功后,调用navigateB ...

  5. 在vue中无论使用router-link 还是 @click事件,发现都没法从列表页点击跳转到内容页去

    在vue中如论使用router-link 还是 @click事件,发现都没法从列表页点击跳转到内容页去,以前都是可以的,想着唯一不同的场景就是因为运用了scroll组件(https://ustbhua ...

  6. vue 详情跳转至列表页 实现列表页缓存

    甲爸爸提了一个需求,希望公众号内的商城能够像app一样,从商品详情页跳转至列表页及其他列表页时,可以实现列表页缓存(数据不刷新.位置固定到之前点的商品的位置) 本来想着scrollBehavior应该 ...

  7. 微信小程序云开发-数据库-列表页携带id跳转到详情页

    一.新建页面 新建列表页"pages/goodslist/goodslist",新建列表详情页"pages/gooddetail/gooddetail"  二. ...

  8. dedecms讲解-arc.listview.class.php分析,列表页展示

    ./plus/list.php - 动态展示栏目列表页(也可能是频道封面)arc.listview.class.php 是dedecms的列表页的相关处理类__construct()         ...

  9. dede列表页分页地址优化(不同url相同内容问题解决)<转自http://www.966266.com>

    <注明,完全转自http://www.966266.com/seoblog/?p=75> 存在问题 DEDE默认分类分页地址存在不同URL相同内容问题,导致内容重复,对SEO非常不利.情况 ...

随机推荐

  1. Window 10 :我的性能优化:那效果,杠杠的!

    微软的 windows 10,不错! 当全新安装后,性能总觉得别别扭扭,不那么干净利落. 下面就是我的个人优化措施,期间有很多技术性的操作,如果你没有动手能力,或者是技术小白,可以不用再看了! (1) ...

  2. position absolute定位之所属的containing box

    http://www.w3.org/TR/CSS2/visudet.html#containing-block-details http://www.zhihu.com/question/199267 ...

  3. jquery.fileupload插件 ie9下不支持上传

    根据https://github.com/blueimp/jQuery-File-Upload/wiki/Browser-support The following browsers support ...

  4. vim中文手册

    http://vimcdoc.sourceforge.net/doc/help.html

  5. pom.xml 配置maven私服

    1.pom.xml 配置maven私服 <repositories>       <repository>        <id>caf_repositories& ...

  6. Python 常用类库

    python除了关键字(keywords)和内置的类型和函数(builtins),更多的功能是通过libraries(即modules)来提供的. 常用的libraries(modules)如下: 1 ...

  7. [Unity3D] 01 - Try Unity3D

    01. Move and Rotate 标准全局坐标系 Keyboard using UnityEngine; using System.Collections; public class NewBe ...

  8. mongo数据库查询结果不包括_id字段方法

    db.GPRS_PRODUCT_HIS_FEE.find({"条件字段" : "412171211145135"},{_id:0}) db.GPRS_PRODU ...

  9. informix中的时间计算

    今天看SUN服务器是的mail(vi   /var/mail/xxxuser),发现定时任务上的一些存储过程执行有错误,其中有一个错误是long transaction,长事务错误,到数据库一查,天哪 ...

  10. N76E003系统时钟

    系统时钟源N76E003共有3种系统时钟源,包括: 内部高速/低速振荡器.外部输入时钟.它们每一个都可以作为N76E003的系统时钟源.开启不同的时钟源可能会影响到多功能引脚P3.0/XIN .内部振 ...