首页 >后端开发 >php教程 > 正文

PHPCMS v9 如何在手机端栏目绑定模板

转载2019-04-22 09:20:3402003
前段时间听朋友说phpcms的手机端,模块是有了,但是有些地方用的还不是很舒服,其中移动端栏目无法绑定模板就不是很方便。如图,所有的栏目绑定的模板是固定的。本篇文章主要讲述了PHPCMS v9 如何在手机端栏目绑定模板,有需要的朋友可以看一下。


这次咱们就来处理下,移动端如何设置相应的模板。
这里说是设置模板其实有点伪命题,因为设置模板需要开发不少东西,就像phpcms的栏目那样,自己选择模板来绑定,我们这里为了快速、方便有更简单的方法。
我们让移动端的栏目和pc端的栏目绑定一样的模板,这里说绑定一样的模板指的是绑定同样的模板名字。
phpcms pc端模板路径 phpcms\templates\default\content 默认的文件有这些:

如果你pc端的栏目绑定模板规则如下:
图片       category_picyure.html
美女图片 list_picture.html  ----->内容页模板 show_picture.html
帅哥图片 list_picture.html ----->内容页模板 show_picture.html

那么移动端的绑定结果如下 \phpcms\templates\default\wap
图片       category_picyure.html
美女图片 list_picture.html  ----->内容页模板 show_picture.html
帅哥图片 list_picture.html ----->内容页模板 show_picture.html

你只需要在移动端的模板里面添加相应的模板文件,移动端栏目就能自动绑定。
下面是具体的代码修改
1、因为移动端首页模板绑定的是wap\index.html,所以不做修改。
2、打开\phpcms\modules\wap\index.php
  在方法 lists 中,约47行$template = ($TYPE[$typeid]['parentid']==0 && in_array($typeid,array_unique($parentids))) ? $WAP_SETTING['category_template'] : $WAP_SETTING['list_template']; 将其注释
  然后添加代码
/*$template = ($TYPE[$typeid]['parentid']==0 && in_array($typeid,array_unique($parentids))) ? $WAP_SETTING['category_template'] : $WAP_SETTING['list_template']; */
// 改造wap的默认模板 使其跟随pc模板规则走
$setting = string2array($setting);
$template = $setting['category_template'] ? $setting['category_template'] : 'category';
$template_list = $setting['list_template'] ? $setting['list_template'] : 'list';
$template = $child ? $template : $template_list;
// 改造结束

// 重新组装数据 让catgory的模板也能用
if($child){
$catids_str = $arrchildid;
$pos = strpos($catids_str,',')+1;
$catids_str = substr($catids_str, $pos);
$sql = "status=99 AND catid IN ($catids_str)";
$list = $this->db->select($sql, '*', $offset.','.$pagesize,'inputtime DESC');
$total = $this->db->count($sql);
}else{
$list = $this->db->select(array('status'=>'99','catid'=>$catid), '*', $offset.','.$pagesize,'inputtime DESC');
}
//重新组装数据结束
这样category 和list 都绑定了相应的栏目模板。其中数据就是 $list。 你可以使用$list进行遍历。

3、打开\phpcms\modules\wap\index.php
  在方法 show中约206行 $template = $WAP_SETTING['show_template'] ? $WAP_SETTING['show_template'] : 'show'; 将其注释
//$template = $WAP_SETTING['show_template'] ? $WAP_SETTING['show_template'] : 'show';
//处理模板调用
$template = $CAT['setting']['show_template'] ? $CAT['setting']['show_template'] : 'show';
ok 这样phpcms的移动端就处理完成了!

相关教程:PHP视频教程

以上就是PHPCMS v9 如何在手机端栏目绑定模板的详细内容,更多请关注php中文网其它相关文章!

php中文网最新课程二维码

声明:本文转载于:博客园,如有侵犯,请联系admin@php.cn删除

  • 相关标签:PHPCMS v9 绑定模板
  • 相关文章

    相关视频


    网友评论

    文明上网理性发言,请遵守 新闻评论服务协议

    我要评论
  • 专题推荐

    作者信息

    little bottle

    认证0级讲师

    最近文章
    mysql免费版好用么3456
    mysql怎么输入3093
    怎么看mysql安装路径4517
    推荐视频教程
  • PHP数据库编程零基础入门到精通PHP数据库编程零基础入门到精通
  • PHP经典算法面试题PHP经典算法面试题
  • php7实战开发cms内容管理系统php7实战开发cms内容管理系统
  • ThinkPHP6.0公益直播课ThinkPHP6.0公益直播课
  • 视频教程分类