首页 » SEO优化 » php手机模版技巧_PHPCMS v9 若安在手机端栏目绑定模板

php手机模版技巧_PHPCMS v9 若安在手机端栏目绑定模板

访客 2024-11-13 0

扫一扫用手机浏览

文章目录 [+]

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

这里说是设置模板实在有点伪命题,由于设置模板须要开拓不少东西,就像phpcms的栏目那样,自己选择模板来绑定,我们这里为了快速、方便有更大略的方法。

php手机模版技巧_PHPCMS v9 若安在手机端栏目绑定模板

我们让移动真个栏目和pc真个栏目绑定一样的模板,这里说绑定一样的模板指的是绑定同样的模板名字。

php手机模版技巧_PHPCMS v9 若安在手机端栏目绑定模板
(图片来自网络侵删)

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

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

更多技巧请《转发 + 关注》哦!

相关文章

我国土地利用分类代码的构建与应用

土地利用分类代码是我国土地管理的重要组成部分,是土地资源调查、规划、利用和保护的依据。土地利用分类代码的构建与应用显得尤为重要。本...

SEO优化 2025-02-18 阅读1 评论0

微信跳转微信支付便捷支付体验的秘密武器

移动支付已成为人们日常生活中不可或缺的一部分。作为我国领先的社交平台,微信支付凭借其便捷、安全的支付方式,深受广大用户的喜爱。而微...

SEO优化 2025-02-18 阅读1 评论0

探寻会计科目代码背后的奥秘分类与

会计科目代码是会计信息系统中不可或缺的组成部分,它将企业的经济活动进行分类和归纳,为会计核算、财务分析和决策提供重要依据。本文将从...

SEO优化 2025-02-18 阅读1 评论0