当前位置 : 主页 > SEO实战 > 正文

DedeCMS筛选伪静态跳转移动端JS

原创

重庆seo2016-04-22 08:33:00阅读()JSseo优化伪静态.htaccess多条件筛选A+ / A-

DedeCMS筛选伪静态跳转移动端JS

       大家对本博客帖子《DedeCMS多条件筛选以筛选词为标题》即最新版DedeCMS V5.7自定义筛选功能基本都能掌握了,接下来分享本人研究整理的一个后台管理移动端、PC用JS代码匹配跳转,如果还想做成伪静态,文章有点长就慢慢看咯。

dede筛选移动端pc端自适应模板跳转功能

一个后台管理生成移动端和PC端的静态页面

       如果用一个后台管理PC和移动端,不用dede默认的移动端模板,参考文章《DedeCMS一个后台管理PC和移动端纯静态非官方版》。

动态列表判断当前设备自动跳转

       筛选列表为动态列表,未作伪静态前,一般路径为:域名/plus/list.php?tid=1。移动端的静态页面实际上是依靠更新时切换模板实现的,但对筛选的动态列表却不能实现移动端和PC端模板的自动选择。经笔者测试有效方法如下:

       1.复制/plus目录下的list.php更名为wap_list.php;

       2.复制/include目录下arc.sglistview.class.php和arc.listview.class.php并分别更名为wap_arc.sglistview.class.php和wap_arc.listview.class.php;

       3.打开wap_list.php找到

include(DEDEINC."/arc.sglistview.class.php");
    $lv = new SgListView($tid,$cArr);
} else {
    include(DEDEINC."/arc.listview.class.php");

       修改为

include(DEDEINC."/wap_arc.sglistview.class.php");
    $lv = new SgListView($tid,$cArr);
} else {
    include(DEDEINC."/wap_arc.listview.class.php");

       4.打开/include/wap_arc.sglistview.class.php,v5.7版本在2015年6月更新后增加了移动端的自适应,如果是老版本的找到相应的位置修改就好,大概在227行,/include/wap_arc.listview.class.php,大概在266行,橙色部分为增加内容:"/pc/"和"/wap/"为/templates目录下的模板路径,根据实际情况填写

//初始化列表模板,并统计页面总数
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$this->TypeLink->TypeInfos['templist'];
$tempfile = str_replace("{tid}",$this->TypeID,$tempfile);
$tempfile = str_replace("{cid}",$this->ChannelUnit->ChannelInfos['nid'],$tempfile);
//增加wap
$tempfile = str_replace("/pc/","/wap/",$tempfile)
if(!file_exists($tempfile))
{
$tempfile = str_replace("/wap/","/pc/",$tempfile);
}
//增加wap

       5.用《DedeCMS一个后台管理PC和移动端纯静态非官方版》的方法需要PC和移动端模板下的各个频道所使用的模板名称完全一样。

       6.跳转代码很多种,文章《DedeCMS电脑端列表和内容跳转到对应移动端》是静态列表,下面是动态列表的方法。

       在系统-系统基本参数-添加新变量:变量名为stylewap,变量值为wap,参数说明为移动端模板,把以下代码放到相应的列表模板即可:

<meta http-equiv="mobile-agent" content="format=xhtml;url={dede:global.stylewap/}/plus/wap_list.php?tid={dede:field.id/}">
<script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf("?mobile")<0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href="{dede:global.stylewap/}/plus/wap_list.php?tid={dede:field.id/}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>

       DedeCMS筛选伪静态规则请看下一页。

扩展阅读

本文地址:https://www.vi586.com/case/271.html
版权声明:原创文章,版权归重庆SEO吖七所有,欢迎分享本文,支持原创,转载请保留出处

赞(9)