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

little bottle
发布: 2019-04-22 09:20:34
转载
3481人浏览过

前段时间听朋友说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速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:博客园网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号