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非常不利.情况 ...
随机推荐
- Lua格式化输出
我们知道lua中可以用".."连接字符串,可以起到一部分格式化字符串的作用,但是如果字符串较长或者有特殊的格式转换操作(如十六进制转换),用".."就会很繁琐且 ...
- web.py开发
web.py需要使用python2.X,所以安装python版本2.7.9 web.py 是一个轻量级Python web框架,它简单而且功能强大 web.py安装 安装python (1)使用pip ...
- CIO需加强对战略管理层面的掌控-精华篇
当代CIO面临提升信息化作用的新机遇.CIO在企业中,不能满足于职能性的技术支撑角色,要找到新的着力点,以发挥信息化在全局战略中的作用,把信息化力量聚焦于做强做优,提高国际竞争力上来,成为企业不可或缺 ...
- HTML标签嵌套规则
摘要: 最近在整理项目时发现有些同事写的页面代码嵌套的太多,而且有些嵌套不对,比如<a><div>内容</div></a>.虽然功能实现了,但是对于浏 ...
- ajax简单手写了一个猜拳游戏
使用ajax简单写一个猜拳游戏 HTML代码 <!DOCTYPE HTML> <html lang="en-US"> <head> <me ...
- python中交换两个值的方法
a = 4b = 5 #第1种c = 0c = aa = bb = c #第2种a = a+bb = a-ba = a-b #第3种a,b = b,a 第三种办法本质上是元组之间的赋值 print(& ...
- 【代码审计】CLTPHP_v5.5.3后台目录遍历漏洞分析
0x00 环境准备 CLTPHP官网:http://www.cltphp.com 网站源码版本:CLTPHP内容管理系统5.5.3版本 程序源码下载:https://gitee.com/chich ...
- 使用 urllib 设置代理服务
(1) 如果我们一直用同一个IP去请求同一个网站上的网页,久了之后可能会被该网站服务器屏蔽,因此我们可以使用代理IP来发起请求,代理实际上指的就是代理服务器(2) 当我们使用代理IP发起请求时,服务器 ...
- oracle nvl,having的用法
select oi.order_id,opl.payment_no,opl.back_no, oi.commit_time, oi.receive_mobile, oi.receive_user, n ...
- 【摘抄】C++程序员练级攻略
摘抄自互联网文章 作为C++程序员,或者说程序员一定要提升自己: 专访李运华:程序员如何在技术上提升自己-CSDN.NET专访徐宜生:坚决不做代码搬运工!-CSDN.NET 上面两个文章我觉得都不错. ...