PHPCMS v9 手机端栏目绑定模板

phpcms的手机端,模块是有了,可是有些地方用的还不是很舒服,其中移动端栏目没法绑定模板就不是很方便。如图,全部的栏目绑定的模板是固定的php

 

此次我们就来处理下,移动端如何设置相应的模板。html

这里说是设置模板其实有点伪命题,由于设置模板须要开发很多东西,就像phpcms的栏目那样,本身选择模板来绑定,咱们这里为了快速、方便有更简单的方法。sql

咱们让移动端的栏目和pc端的栏目绑定同样的模板,这里说绑定同样的模板指的是绑定一样的模板名字。网络

phpcms pc端模板路径 phpcms\templates\default\content   默认的文件有这些this

若是你pc端的栏目绑定模板规则以下:spa

  • 图片                 category_picyure.html
    • 美女图片               list_picture.html  ----->内容页模板  show_picture.html
    • 帅哥图片               list_picture.html       ----->内容页模板  show_picture.html

 那么移动端的绑定结果以下  \phpcms\templates\default\wap code

  • 图片                 category_picyure.html
    • 美女图片               list_picture.html  ----->内容页模板  show_picture.html
    • 帅哥图片               list_picture.html       ----->内容页模板  show_picture.html

 你只须要在移动端的模板里面添加相应的模板文件,移动端栏目就能自动绑定。htm

下面是具体的代码修改blog

一、由于移动端首页模板绑定的是wap\index.html,因此不作修改。图片

二、打开\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进行遍历。

三、打开\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的移动端就处理完成了!

本文由 襄阳艾特网络  http://www.xyat.cn 原创,转载请注明出处。

相关文章
相关标签/搜索