电脑版静态效果:
http://www.xxx.cn/view/
http://www.xxx.cn/view/3414.html
移动版伪静态效果:
http://m.xxx.cn/view/
http://m.xxx.cn/view/3414.html
修改或者覆盖文件之前请备份以下5个文件
\m\index.php
\m\list.php
\m\view.php
\include\arc.listview.class.php
\include\typelink.class.php
修改后台系统设置——系统基本参数——核心设置——关闭支持多站点
电脑版静态生成这里就不多说了,移动版伪静态操作教程如下:
1.移动版域名 m.123.com 解析并指向绑定目录到网站目录的m文件夹
2.后台-系统配置 添加变量 (为了使用绝对路径,使用电脑版的文章图片,为了移动版模板css、js、images使用绝对路径)
变量名称:cfg_mobile
变量类型:文本
参数说明:手机版网址
变量值:http://m.xxx.com
所属组:站点设置
变量名称:cfg_rewritem
变量类型:布尔(Y/N)
参数说明:手机版伪静态
变量值:Y
所属组:站点设置
3.\m\index.php 修改成永远是动态,不生成index.html
把里面的:
1
2
3
4
5
6
7
8
9
10
$row[‘showmod’] = isset($row[‘showmod’])? $row[‘showmod’] : 0;
if ($row[‘showmod’] == 1)
{
$pv->SaveToHtml(dirname(__FILE__).‘/index.html’);
include(dirname(__FILE__).‘/index.html’);
exit();
} else {
$pv->Display();
exit();
}
替换成:
1
2
$pv->Display();
exit();
4.\m\list.php 增加伪静态判断
把里面的:
1
$tid = (isset($tid) && is_numeric($tid) ? $tid : 0);
替换成:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
if($cfg_rewritem == ‘Y’)
{
$typedir = parse_url($tid, PHP_URL_PATH);
$PageNo = stripos(GetCurUrl(), ‘.html’) ? intval(str_replace(‘.html’, ”, end(explode(“_”, GetCurUrl())))) : 1;
$tinfos = $dsql->GetOne(“SELECT * FROM `dede_arctype` WHERE typedir=’/$typedir’ or typedir='{cmspath}/$typedir’”);
if(is_array($tinfos))
{
$tid = $tinfos[‘id’];
$typeid = GetSonIds($tid);
$row = $dsql->GetOne(“Select count(id) as total From `dede_archives` where typeid in({$typeid})”);
$TotalResult = is_array($row) ? $row[‘total’] : 0;
}
else
{
$tid = 0;
}
}
else
{
$tid = (isset($tid) && is_numeric($tid) ? $tid : 0);
}
5.\m\view.php 增加伪静态判断
在:
1
$t1 = ExecTime();
下面加入:
1
2
3
4
if($cfg_rewritem == ‘Y’)
{
$aid = stripos(GetCurUrl(), ‘.html’) ? intval(str_replace(‘.html’, ”, end(explode(“/”, GetCurUrl())))) : 0;
}
6.\include\arc.listview.class.php 增加移动版伪静态分页功能,找到
1
global $cfg_rewrite;
替换成:
1
global $cfg_rewrite,$cfg_rewritem;
继续查找:
1
2
$geturl = “tid=”.$this->TypeID.“&TotalResult=”.$this->TotalResult.“&”;
$purl .= ‘?’.$geturl;
替换成:
1
2
3
4
5
6
7
8
9
if($cfg_rewritem == ‘Y’)
{
$purl = “”;
}
else
{
$geturl = “tid=”.$this->TypeID.“&TotalResult=”.$this->TotalResult.“&”;
$purl .= ‘?’.$geturl;
}
继续查收:
1
return $plist;
在它的上面加入:
1
2
3
4
if($cfg_rewritem == ‘Y’)
{
$plist = preg_replace(“/PageNo=(\d+)/i”,‘list_’.$this->TypeID.‘_\\1.html’,$plist);
}
7.\include\typelink.class.php 修改移动版{dede:field name=’position’/}伪静态,找到
1
$indexpage = “<a href=’index.php’>”.$this->indexName.“</a>”;
替换成:
1
2
3
4
5
6
7
8
if($GLOBALS[‘cfg_rewritem’] == ‘Y’)
{
$indexpage = “<a href=’”.$GLOBALS[‘cfg_mobile’].“‘>”.$this->indexName.“</a>”;
}
else
{
$indexpage = “<a href=’index.php’>”.$this->indexName.“</a>”;
}
继续查找:
1
return ‘list.php?tid=’.$typeinfos[‘id’];
替换成:
1
2
3
4
5
6
7
8
if($GLOBALS[‘cfg_rewritem’] == ‘Y’)
{
return GetTypeUrl($typeinfos[‘id’],MfTypedir($typeinfos[‘typedir’]),$typeinfos[‘isdefault’],$typeinfos[‘defaultname’],$typeinfos[‘ispart’],$typeinfos[‘namerule2’],$typeinfos[‘moresite’],$typeinfos[‘siteurl’],$typeinfos[‘sitepath’]);
}
else
{
return ‘list.php?tid=’.$typeinfos[‘id’];
}
8.移动版模板中使用标签
{dede:global.cfg_mobile/} http://m.xxx.com
[field:global.cfg_basehost/][field:litpic/]
图片用主站的,如:http://www.xx.com/uploads/allimg/180105/20493W4S-0.jpg
{dede:field.body/}
改成
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{dede:field.body runphp=yes}
global $cfg_basehost;
$str = @me;
$search = ‘/(<img.*?)width=([“\’])?.*?(?(2)\2|\s)([^>]+>)/is’;
$search1 = ‘/(<img.*?)height=([“\’])?.*?(?(2)\2|\s)([^>]+>)/is’;
$search2 = ‘#(<img.*?style=”.*?)width:\d+px;([^”]*?.*?>)#i’;
$search3 = ‘#(<img.*?style=”.*?)height:\d+px;([^”]*?.*?>)#i’;
$content = preg_replace($search,‘$1$3’,$str);
$content = preg_replace($search1,‘$1$3’,$content);
$content = preg_replace($search2,‘$1$2’,$content);
$content = preg_replace($search3,‘$1$2’,$content);
@me = $content;
@me = str_replace(‘/uploads/allimg/’, $cfg_basehost.‘/uploads/allimg/’, $content);
{/dede:field.body}
栏目内容 {dede:field.content/}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{dede:field.content runphp=yes}
global $cfg_basehost;
$str = @me;
$search = ‘/(<img.*?)width=([“\’])?.*?(?(2)\2|\s)([^>]+>)/is’;
$search1 = ‘/(<img.*?)height=([“\’])?.*?(?(2)\2|\s)([^>]+>)/is’;
$search2 = ‘#(<img.*?style=”.*?)width:\d+px;([^”]*?.*?>)#i’;
$search3 = ‘#(<img.*?style=”.*?)height:\d+px;([^”]*?.*?>)#i’;
$content = preg_replace($search,‘$1$3’,$str);
$content = preg_replace($search1,‘$1$3’,$content);
$content = preg_replace($search2,‘$1$2’,$content);
$content = preg_replace($search3,‘$1$2’,$content);
@me = $content;
@me = str_replace(‘/uploads/allimg/’, $cfg_basehost.‘/uploads/allimg/’, $content);
{/dede:field.content}
编辑整理:数学课,如若转载,请注明出处:https://www.shuxueke.net/2022/12/15.html