thinkCMF----列表页跳转
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----列表页跳转的更多相关文章
- vue通过id从列表页跳转到对应的详情页
1. 列表页:列表页带id跳转到详情页 详情页:把id传回到后台就可以获取到数据了 2.列表页跳转到详情页并更改详情页的标题 列表页:带id和页面标题的typeid跳转到详情页 详情页:在html绑定 ...
- VUE通过id从列表页跳转到相对的详情页
新闻列表页面: 在这里我用a标签进行跳转,在vue里面可以这样写<router-link></router-link> 1 <router-link :to=" ...
- 夺命雷公狗ThinkPHP项目之----企业网站23之网站前台二级分类的跳转(URL跳转到列表页或产品页)
我们现在开始做实现我们的二级菜单如何跳转到指定的列表页或者产品也呢?? 我们分享下数据库情况: 我们的数据库里提前给我们预留了一个cate_type的字段,那么我们可以让这个字段进行判断,从而遍历出指 ...
- 微信小程序页面列表与详情页跳转的正确姿势
初学小程序,碰到列表与详情页跳转遇到的问题,记录一下. 一.问题 1个列表页: 1个详情页: 列表页代码: onLoad:异步查询数据并setData 详情页代码: 保存成功后,调用navigateB ...
- 在vue中无论使用router-link 还是 @click事件,发现都没法从列表页点击跳转到内容页去
在vue中如论使用router-link 还是 @click事件,发现都没法从列表页点击跳转到内容页去,以前都是可以的,想着唯一不同的场景就是因为运用了scroll组件(https://ustbhua ...
- vue 详情跳转至列表页 实现列表页缓存
甲爸爸提了一个需求,希望公众号内的商城能够像app一样,从商品详情页跳转至列表页及其他列表页时,可以实现列表页缓存(数据不刷新.位置固定到之前点的商品的位置) 本来想着scrollBehavior应该 ...
- 微信小程序云开发-数据库-列表页携带id跳转到详情页
一.新建页面 新建列表页"pages/goodslist/goodslist",新建列表详情页"pages/gooddetail/gooddetail" 二. ...
- dedecms讲解-arc.listview.class.php分析,列表页展示
./plus/list.php - 动态展示栏目列表页(也可能是频道封面)arc.listview.class.php 是dedecms的列表页的相关处理类__construct() ...
- dede列表页分页地址优化(不同url相同内容问题解决)<转自http://www.966266.com>
<注明,完全转自http://www.966266.com/seoblog/?p=75> 存在问题 DEDE默认分类分页地址存在不同URL相同内容问题,导致内容重复,对SEO非常不利.情况 ...
随机推荐
- win上的某个端口是否开启
1.添加Telnet服务 控制面板-->程序-->打开或关闭windows功能 2.配置Telnet为自动并开启服务 计算机-->服务和应用程序-->服务 3.telnet - ...
- [Err] 1231 - Variable 'sql_mode' can't be set to the value of 'NULL
在MYSQL还原语句的时候,报: [Err] - Variable 'sql_mode' can't be set to the value of 'NULL 解决办法:打开SQL语句,把里面的注释给 ...
- 关于测试中哪些信息需要放到jira上面
1.每个新需求的功能点,全部在jira上一一呈现 2.每个bug也一样在jira上一一呈现 3.任务一个需要优化改进的点也一一在jira上呈现 然后程序员一直开发新功能和修改新bug,测试人员负责bu ...
- 8 -- 深入使用Spring -- 8... Spring整合Hibernate
8.8 Spring整合Hibernate 8.8.1 Spring提供的DAO支持 8.8.2 管理Hibernate的SessionFactory 8.8.3 实现DAO组件的基类 8.8.4 传 ...
- ios开发之--使用UILabel Category 计算UILabel内容大小
在此仅做记录,代码如下:
- python运行显示编码错误
python中运行显示编码错误一般有2种原因: 编码与译码的方式不一致 在编写Python时,当使用中文输出或注释时运行脚本,会提示错误信息: SyntaxError: Non-ASCII chara ...
- 绑定方式开始服务&调用服务的方法
1.编写activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/androi ...
- mysql的wait_timeout配置(此处处理方法是有问题的,不建议作为操作参考)
mysql数据库有一个wait_timeout的配置,默认值为28800(即8小时). 在默认配置不改变的情况下,如果连续8小时内都没有访问数据库的操作,再次访问mysql数据库的时候,mysql数据 ...
- 基于Cocos2d-x学习OpenGL ES 2.0系列——编写自己的shader(2)
在上篇文章中,我给大家介绍了如何在Cocos2d-x里面绘制一个三角形,当时我们使用的是Cocos2d-x引擎自带的shader和一些辅助函数.在本文中,我将演示一下如何编写自己的shader,同时, ...
- 使用es6的蹦床函数解决递归造成的堆栈溢出
首先,我们先定义一个函数,使用递归的思想写求和的方法: function sum(x, y) { if (y > 0) { return sum(x + 1, y - 1); } else ...