织梦手机端静态模块增加发布文章后自动生成移动版首页、列表页、文章页、上一篇_织梦插件

织梦DedeCMS*新版手机移动端静态生成模块插件

让织梦DedeCMS支持手机移动端的静态页生成,更加利于SEO

使用后的后台更新静态页的位置效果如下图:

栏目更新


使用说明:

替换dede、include目录 注意备份你的程序(因未备份出现问题作者不负一切责任)

本次修改实现了 移动站点静态生成(基于*新版本修改)

修改处有代码注释,有基础的同学可以自己研究

移动端文章URL调用<a href="/m[field:arcurl]">标签</a>

移动端当前栏目URL调用<a href=" /m{dede:field name='typeurl'/}">标签</a>

在原有电脑链接标签前面加/m


pc自动跳转通用链接

<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="/m"+location.pathname+location.search;}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>


移动模版与pc模版有什么变化?

如:pc index.htm 移动 index_m.htm

模块下载地址:

加入下面*群获得


增加功能教程如下:

1.后台-系统配置-性能选项

2.后台-系统配置,添加变量

变量名称:cfg_makemobile

变量类型:布尔(Y/N)

参数说明:移动版生成静态

变量值:Y

所属组:站点设置


DedeCms织梦手机端生成静态模块增加发布文章后自动生成移动版首页、列表页、文章页、上一篇

3.\dede\task_do.php  (dede为后台目录) 找到

if(is_array($nextRow))

{

    $envs['aid'] = $nextRow['id'];

    $arc = new Archives($nextRow['id']);

    $arc->MakeHtml();

}


在它的下面加入

//发布文章后自动生成移动版文章页、上一篇下一篇 开始

if($cfg_makemobile == 'Y')

{

    define('DEDEMOB', 'Y');

    $arc = new Archives($aid);

    $arc->MakeHtml();

    if(is_array($preRow))

    {

        $envs['aid'] = $preRow['id'];

        $arc = new Archives($preRow['id']);

        $arc->MakeHtml();

    }

    if(is_array($nextRow))

    {

        $envs['aid'] = $nextRow['id'];

        $arc = new Archives($nextRow['id']);

        $arc->MakeHtml();

    }

}

//发布文章后自动生成移动版文章页、上一篇下一篇 结束


继续找到

$pv->SaveToHtml($homeFile);

在它的下面加入

//发布文章后自动生成移动版首页 开始

if($cfg_makemobile == 'Y')

{

    $templet = str_replace("{style}", $cfg_df_style, $row['templet']);

    $templet = str_replace('.htm','_m.htm',$templet);

    $homeFile = dirname(__FILE__).'/'.str_replace("../", '../m/',$row['position']);

    $homeFile = str_replace("//", "/", str_replace("\\", "/", $homeFile));

    $fp = fopen($homeFile, 'w') or die("无法更新移动版主页到:$homeFile 位置");

    fclose($fp);

    $tpl = $cfg_basedir.$cfg_templets_dir.'/'.$templet;

    if(!file_exists($tpl))

    {

        $tpl = $cfg_basedir.$cfg_templets_dir.'/default/index_m.htm';

        if(!file_exists($tpl)) exit("无法找到移动版主页模板:$tpl ");

    }

   $GLOBALS['_arclistEnv'] = 'index';

    $pv->SetTemplet($tpl);

    $pv->SaveToHtml($homeFile);

}

//发布文章后自动生成移动版首页 结束


*后继续找到

require_once(DEDEINC."/arc.listview.class.php");

$lv = new ListView($tid);

$lv->CountRecord();

$lv->MakeHtml();

$lv->Close();

在它的下面加入

//发布文章后自动生成移动版列表页 开始

if($cfg_makemobile == 'Y')

{

    define('DEDEMOB', 'Y');

    $lv = new ListView($tid);

    $lv->CountRecord();

    $lv->MakeHtml();

    $lv->Close();

}

//发布文章后自动生成移动版列表页 结束


附件下载:

task_do.zip


2017/6/14      修改手机静态的{dede:field name='position'/}为静态

打开 \include\typelink.class.php 找到

$indexpage = "<a href='index.php'>".$this->indexName."</a>";

改成

$indexpage = "<a href='".$GLOBALS['cfg_mobileurl']."'>".$this->indexName."</a>";


继续找到

return 'list.php?tid='.$typeinfos['id'];

二级目录做手机站的 改成

return $GLOBALS['cfg_mobileurl'].GetTypeUrl($typeinfos['id'],MfTypedir($typeinfos['typedir']),$typeinfos['isdefault'],$typeinfos['defaultname'],$typeinfos['ispart'],$typeinfos['namerule2'],$typeinfos['moresite'],$typeinfos['siteurl'],$typeinfos['sitepath']);


二级域名做手机站的 改成

return GetTypeUrl($typeinfos['id'],MfTypedir($typeinfos['typedir']),$typeinfos['isdefault'],$typeinfos['defaultname'],$typeinfos['ispart'],$typeinfos['namerule2'],$typeinfos['moresite'],$typeinfos['siteurl'],$typeinfos['sitepath']);


2017/7/18    采集侠插件支持采集自动生成手机版首页、列表页、内容页、上一篇下一篇

打开 \Plugins\apps\CaiJiXia\index.php 找到

$this->GH();

在它的下面加入

$this->MGH();//生成手机版首页

$this->MGL($r['typeid']);//生成手机版列表页

$this->MMH($r['id']);//生成手机版内容页

$this->MML($r['id'],$r['typeid']);//生成手机版上一篇下一篇


继续找到

function cjxxml(){

在它的上面加入

//生成手机版首页

function MGH()
{
         if($this->GV('makeindex')=='Y' && $this->GV('makemobile') == 'Y'){
                   $this->LC('arc.partview');
                   $envs = $_sys_globals = array();
                   $envs['aid'] = 0;
                   $pv = new PartView();
                   $row = cjxdb('homepageset')->find();
                   if(isset($row['showmod']) && $row['showmod']==0) return false;
                   $templet = cjx_str_replace("{style}", $this->GV('df_style'), $row['templet']);
                   $templet = str_replace('.htm','_m.htm',$templet);
                   $homeFile = PLUGINS.'/'.str_replace("../", '../m/',$row['position']);
                   $homeFile = cjx_str_replace("//", "/", cjx_str_replace("\\", "/", $homeFile));
                   $fp = fopen($homeFile, 'w') or die("无法更新移动版主页到:$homeFile 位置");
                   fclose($fp);
                   $tpl = $this->GV('basedir').$this->GV('templets_dir').'/'.$templet;
                   $GLOBALS['_arclistEnv'] = 'index';
                   $pv->SetTemplet($tpl);
                   $pv->SaveToHtml($homeFile);
                   $pv->Close();
         }
}
//生成手机版列表页
function MGL($id)
{
         if($this->GV('make_andcat')=='Y'){
                   $this->LC('arc.listview');
                   $topids = cjx_explode(',', GetTopids($id));
                                     //some bug
                   $topids = array_unique($topids);
                   define('DEDEMOB', 'Y');
                   foreach($topids as $tid){
                            $lv = new ListView($tid);
                            $lv->MakeHtml(0,5);
                            $lv->Close();
                   }
         }
}
//生成手机版内容页
function MMH($id)
{
         define('DEDEMOB', 'Y');
         $arc = new Archives($id);
         $arc->MakeHtml();
}
//生成手机版上一篇下一篇
function MML($id,$ty)
{
         if($this->GV('make_prenext')=='Y'){
                   $pre = cjxdb('arctiny')->where("id<$id And arcrank>-1 And typeid=$ty")->order('id desc')->find();
                   if($pre){
                            define('DEDEMOB', 'Y');
                            $arc = new Archives($pre['id']);
                            $arc->MakeHtml();
                   }
         }
}

完成。