您现在的位置是:首页 > cms教程 > DedeCMS教程DedeCMS教程

织梦cms怎么实现伪静态URL

冷安2023-12-12DedeCMS教程已有人查阅

导读我们知道织梦模板可以在后台直接设置成静态HTML,但是如果你是一个数据量非常大的网站,更改模板后,重新生成HTML,试试想10W数据,重新生成一遍的难度。

我们知道织梦模板可以在后台直接设置成静态HTML,但是如果你是一个数据量非常大的网站,更改模板后,重新生成HTML,试试想10W数据,重新生成一遍的难度。所在这里我想到了一个用urlwrite实现的伪静态URL的方法。
提示:用urlwrite实现的伪静态,服务器支持urlwrite。
修改方法
编辑文件
include/inc_channel_unit_functi*****.php
第107行改为
if($rank!=0||$ismake==-1||$typeid==0||$money>0){ //动态文章
//return $GLOBALS['cfg_plus_dir']."/view.php?aid=$aid";
//keminar 修改
$articleDir = MfTypedir($artdir);
if($artdir=="") $articleDir = $GLOBALS['cfg_cmspath'].$GLOBALS['cfg_arcdir'];
return $articleDir."/".GetPinyin($title)."_aid_".$aid.".html";
}
第52行改为
if($rank!=0||$ismake==-1||$typeid==0||$money>0) //动态文章
{
if($GLOBALS['cfg_multi_site']=='Y')
{
$siteurl = $GLOBALS['cfg_basehost'];
}
//return $siteurl.$GLOBALS['cfg_plus_dir']."/view.php?aid=$aid";
//keminar 修改
$articleDir = MfTypedir($artdir);
if($artdir=="") $articleDir = $GLOBALS['cfg_cmspath'].$GLOBALS['cfg_arcdir'];
return $siteurl.$articleDir."/".GetPinyin($title)."_aid_".$aid.".html";
}
第146行改为
if($isdefault==-1)
{
//$reurl = $GLOBALS["cfg_plus_dir"]."/list.php?tid=".$typeid;
//keminar 修改
$reurl = $GLOBALS["cfg_cmspath"]."/".$typedir."_tid_".$typeid.".html";
}else if($ispart>0)
修改文件
include/inc_arclist_view.php
第810行改为
$purl = $this->GetCurUrl();
//keminar 修改
$t = strpos($purl,'_tid_');
$purl = substr($purl,0,$t);
$geturl = "tid_".$this->TypeID."_";
//$hidenform = "<input type='hidden' name='typeid' value='".$this->TypeID."'>\r\n";
//$hidenform .= "<input type='hidden' name='totalresult' value='".$this->totalresult."'>\r\n";
$purl .= "_".$geturl;
//获得上一页和下一页的链接
if($this->pageno != 1){
$prepage.="<a href='".$purl."pageno_".$prepagenum.".html'>上一页</a>\r\n";
$indexpage="<a href='".$purl."pageno_1.html'>首页</a>\r\n";
}
else{
$indexpage="<a href='#'>首页</a>\r\n";
}
if($this->pageno!=$totalpage && $totalpage>1){
$nextpage.="<a href='".$purl."pageno_".$nextpagenum.".html'>下一页</a>\r\n";
$endpage="<a href='".$purl."pageno_".$totalpage.".html'>末页</a>\r\n";
}
else{
$endpage="末页\r\n";
}
//获得数字链接
$listdd="";
$total_list = $list_len * 2 + 1;
if($this->pageno >= $total_list) {
$j = $this->pageno-$list_len;
$total_list = $this->pageno+$list_len;
if($total_list>$totalpage) $total_list=$totalpage;
}else{
$j=1;
if($total_list>$totalpage) $total_list=$totalpage;
}
for($j;$j<=$total_list;$j++){
if($j==$this->pageno) $listdd.= "<strong>$j</strong>\r\n";
else $listdd.="<a href='".$purl."pageno_".$j.".html'>".$j."</a>\n";
}
$plist = "";
//$plist .= "<form name='pagelist' action='".$this->GetCurUrl()."'>$hidenform";
$plist .= $maininfo.$indexpage.$prepage.$listdd.$nextpage.$endpage;
if($totalpage>$total_list){
$plist.="<input type='text' name='pageno' id='pageno' value='".$this->pageno."'>\r\n";
$plist.="<input type='button' id='button' name='plistgo' value='GO' onclick='plistgo();'>\r\n";
}
//$plist .= "</form>\r\n";
$plist .= "<script type='text/javascript'>\r\n
function plistgo(){
var pageno = document.getElementById(\"pageno\").value;
window.location.href='".$purl."pageno_'+pageno+'.html';
};</script>";
return $plist;
修改模板
templets/jinsuo/article_image.htm
第10行添加
var url = location.href;
var t = url.indexOf('_aid_');
var aurl = url.slice(0,t);
第42行修改
if(npage==2){
if(namehand!='') location.href = namehand+".html";
else location.href = aurl+"_aid_{dede:field name='id'/}"+".html";
}else if(displaytype=='st' && namehand!=''){
location.href = namehand+"_"+(npage-1)+".html";
}else{
location.href = aurl+"_aid_{dede:field name='id'/}_pageno_"+(npage-1)+".html";
}
}
}
//下一张
function dPlayNext(){
if(npage==totalpage){ alert("没有了哦"); }
else{
if(displaytype=='st' && namehand!='') location.href = namehand+"_"+(npage+1)+".html";
else location.href = aurl+"_aid_{dede:field name='id'/}_pageno_"+(npage+1)+".html";

本文标签:

很赞哦! ()

相关源码

  • (自适应响应式)pbootcms食品零食店日化用品网站源码下载基于PbootCMS内核开发的响应式模板,为食品零食、日化用品等行业量身定制。该模板通过可视化设计展现产品特色,帮助企业快速搭建专业官网查看源码
  • 帝国cms7.5品牌连锁店招商加盟商机网站模版源码本模板为招商加盟、创业投资、品牌连锁等商业领域设计,采用帝国CMS7.5内核构建,整体风格简洁大气,突出商业信任感与专业度,适合各类招商加盟项目展示、品牌连锁店宣传等商业应用场景。查看源码
  • (自适应响应式)高端家用办公家具家居桌椅pbootcms模板下载为办公家具企业设计的响应式网站模板,涵盖产品展示、案例呈现、企业介绍等核心模块。通过可视化后台可快速发布实木桌椅、系统家具、办公屏风等产品信息,帮助客户直观了解材质参数与空间搭配方案。查看源码
  • 响应式HTML5家居建材办公家具桌椅pbootcms模板为家居建材、办公家具企业打造的响应式网站模板,同时支持多行业快速适配通过替换文字图片即可转型为其他行业官网,大幅降低开发成本。查看源码
  • WordPress主题模板主题巴巴/博客X主题源码免费下载博客X主题专注于内容创作领域,为博客、资讯类网站提供专业的内容展示解决方案。该模板采用精心设计的布局结构,能够有效提升内容的可读性和用户停留时间。查看源码
  • (自适应响应式)英文外贸汽车零配件五金机械网站模板为汽车零部件制造商与五金机械出口企业打造的响应式网站模板,内置多语言切换功能,支持产品参数表、OEM能力展示等外贸场景需求。通过结构化数据展示帮助海外买家快速理解产品规格。查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐