DedeCms手机端生成静态模块 下载地址
该模块由DedeCms_FAQ(官方QQ群) 管理员small-QQ1531982850强力驱动。
在他的基础上加入【发布文章后自动生成移动版首页、列表页、文章页、上一篇下一篇】
以下教程所修改的文件(utf8/gbk)打包下载:
修改或者覆盖文件之前请备份后台这个文件
\dede\task_do.php
云盘下载 密码: 4f6n
增加功能教程如下:
1.后台-系统配置-性能选项
2.后台-系统配置,添加变量
变量名称:cfg_makemobile
变量类型:布尔(Y/N)
参数说明:移动版生成静态
变量值:Y
所属组:站点设置

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();
}
//发布文章后自动生成移动版列表页 结束
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();
}
}
}
完成。
DedeCMS织梦工场QQ群
群号(23871657)
只适用于讨论dedecms二次开发相关话题,其他闲聊、广告、斗图、捣乱请自重自觉,谢谢合作!
不忘初心 、方得始终
DedeCMS织梦工场 - 致力于把最实用的DedeCms二次开发教程,DedeCms二次开发视频,DedeCms二次开发实例经验,分享给最需要的站长,希望每一位来访的站长都能有所收获!
如果您认为本网站的内容质量不错或者读后成功解决你心中的难题,觉得收获很大,那么不妨小额赞助一下,让我们有动力继续写出高质量的教程与更棒的程序教程。打赏记录
赞助方式
支付宝手机客户端扫描上面的二维码进行赞助
微信手机客户端扫描上面的二维码进行赞助