织梦DEDECMS生成静态手机页面
实现wap手机静态生成
一、添加后台导航栏目链接
1 打开dede/c/c_menu.php,在146行下面添加代码
<m:item name='更新WAP主页' lk='makehtml_homepagewap.php' rank='sys_MakeHtml' target='ma' /> <m:item name='更新WAP栏目' lk='makehtml_listwap.php' rank='sys_MakeHtml' target='ma' /> <m:item name='更新WAP文档' lk='makehtml_archiveswap.php' rank='sys_MakeHtml' target='ma' />
二、更新WAP主页
1.复制文件dede/makehtml_homepage.php,重命名为makehtml_homepagewap.php2.打开makehtml_homepagewap.php,找到一行
clude DedeInclude('templets/makehtml_homepage.htm');
修改为
clude DedeInclude('templets/makehtml_homepagewap.htm');
3.复制文件dede/templets/makehtml_homepage.htm,重命名为makehtml_homepagewap.htm
4打开dede/templets/makehtml_homepagewap.htm 修改21行
<form action="makehtml_homepage.php" method="post" name="form1" target="stafrm">
修改为
<form action="makehtml_homepagewap.php" method="post" name="form1" target="stafrm">
3
4.修改36行,指定生成WAP主页模板
<put name="templet" type="text" id="templet" style="width:300" value="default/wap.htm">
4
5.修改48行,指定生成WAP主页路径
<td height="20" valign="" bgcolor="#FFFFFF"><put name="position" type="text" id="position" value="../m/dex.html" size="30">
6.修改69~70行,“checked”移到“不保存当前选项”,系统默认是提交保存主页模板和路径数据的
<put name="saveset" type="radio" value="0" class="np" checked>
不保存当前选项
<put name="saveset" type="radio" class="np" value="1" >
保存当前选项
END
三、更新WAP栏目
1.复制文件dede/makehtml_list.php,重命名为makehtml_listwap.php
2.打开makehtml_listwap.php,找到一行
clude DedeInclude('templets/makehtml_list.htm');
修改为
clude DedeInclude('templets/makehtml_listwap.htm');
3.复制文件dede/templets/makehtml_list.htm 重命名为makehtml_listwap.htm ,修改第10行
<form name="form1" action="makehtml_list_action.php" method="get" target='stafrm'>
修改为
<form name="form1" action="makehtml_listwap_action.php" method="get" target='stafrm'>
4.复制dede/makehtml_list_action.php 重命名makehtml_listwap_action.php
require_once(DEDEINC."/arc.listview.class.php");
修改为
require_once(DEDEINC."/arc.listwapview.class.php");
5.复制clude/arc.listview.class.php 重命名为arc.listwapview.class.php
if(!file_exists($tempfile))
{
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/list_default.htm";
}
if(!file_exists($tempfile)||!is_file($tempfile))
{
echo "模板文件不存在,无法解析文档!";
exit();
}
替换为
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/list_wap.htm";
修改栏目储存目录,在658-659行后面添加代码,生成的栏目文件保存在文件夹“m”下面
$typedir = MfTypedir('/m/'.$typedir);
修改
function GetMakeFileRule($typeid,$wname,$typedir,$defaultname,$namerule2)
{
$typedir = MfTypedir('/m/'.$typedir);
if($wname=='dex')
代码345-371行是把list第一页复制为首页dex.html的,修改354行修改复制保存路径,在$this->Fields['typedir'])前面添加'/m/'. 如下面10行所示
if($startpage==1)
{
//如果列表启用封面文件,复制这个文件第一页
if($this->TypeLk->TypeInfos['isdefault']==1
&& $this->TypeLk->TypeInfos['ispart']==0)
{
$onlyrule = $this->GetMakeFileRule($this->Fields['id'],"list",$this->Fields['typedir'],'',$this->Fields['namerule2']);
$onlyrule = str_replace("{page}","1",$onlyrule);
$list_1 = $this->GetTruePath().$onlyrule;
$murl = MfTypedir('/m/'.$this->Fields['typedir']).'/'.$this->Fields['defaultname'];
//如果启用远程发布则需要进行判断
if($cfg_remote_site=='Y'&& $isremote == 1)
{
//分析远程文件路径
$remotefile = $murl;
$localfile = '..'.$remotefile;
$remotedir = preg_replace('/[^\/]\.html/', '',$remotefile);
//不相等则说明已经切换目录则可以创建镜像
$this->ftp->rmkdir($remotedir);
$this->ftp->upload($localfile, $remotefile, 'acii');
}
$dexname = $this->GetTruePath().$murl;
copy($list_1,$dexname);
}
}
return $murl;
}
四、更新WAP文档
1.复制dede/makehtml_archives.php 重命名为makehtml_archiveswap.php 修改一行
clude DedeInclude('templets/makehtml_archives.htm');
修改为
clude DedeInclude('templets/makehtml_archiveswap.htm');
2.复制dede/templets/makehtml_archives.htm 重命名为makehtml_archiveswap.htm 修改13行form提交地址
<form name="form1" action="makehtml_archives_action.php" method="get" target='stafrm'>
修改为
<form name="form1" action="makehtml_archiveswap_action.php" method="get" target='stafrm'>
3.复制dede/makehtml_archives_action.php 重命名为makehtml_archiveswap_action.php 修改13行
require_once(DEDEINC."/arc.archives.class.php");
修改为
require_once(DEDEINC."/arc.archiveswap.class.php");
4.复制clude/arc.archives.class.php 重命名为arc.archiveswap.class.php
修改文章页储存位置,476行,站点真实路径后面添加"/m/" 如下第9行所示
/
获得站点的真实根路径
@aess public
@return strg
/
function GetTruePath()
{
$TRUEpath = $GLOBALS["cfg_basedir"].'/m/';
return $TRUEpath;
}
修改获得模板文件位置,屏蔽528-536行代码,后面添加调用模版路径
/ if(!empty($this->Fields['templet']))
{
$filetag = MfTemplet($this->Fields['templet']);
if( !preg_match("#\/#", $filetag) ) $filetag = $GLOBALS['cfg_df_style'].'/'.$filetag;
}
else
{
$filetag = MfTemplet($this->TypeLk->TypeInfos["temparticle"]);
}/
$filetag = $GLOBALS['cfg_df_style'].'/'.'article_wap.htm';
是将上面的代码注释掉
注意事项
DEDE手机目录是M
网站设计
- 静宁会SEO的网站建设公司:全面提升您的网络影
- 提升在线业务的关键:选择最佳的丽水网站建设
- 浙江网站优化发展潜力如何
- 井研专业的网站建设公司:打造您的在线品牌
- 灵山SEO网站建设公司:提升您的在线业务表现
- 蒙城网站建设优化公司:提升您网站表现的理想
- 阳谷企业网站优化:提升线上业务力的关键
- 樟树专业的网站建设公司:打造您在线业务的坚
- 通河百度SEO排名的策略与技巧
- 重庆百度快照排名如何进行精准的客户引流
- 重庆百度快照排名
- 常宁便宜的建站公司:助您轻松打造在线业务
- 巫溪百度网站优化:提升网站曝光率与流量的关
- 湖北整站优化怎么做才能放大客户需求
- 闸北网站建设多少钱?全面解析与预算规划
- 辽宁企业网站优化怎么做电话营销