温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

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

发布时间:2020-07-16 10:46:32 来源:亿速云 阅读:196 作者:Leah 栏目:编程语言

如何使用PHPCMS v9在手机端栏目绑定模板?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

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


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

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

如果你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的移动端就处理完成了!

关于 如何使用PHPCMS v9在手机端栏目绑定模板问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI