本文实例讲述了织梦dedecms将列表页重复的第一页去除的方法。分享给大家供大家参考。具体分析如下:
织梦程序的文章列表页首页和列表页第一页是一样的,程序是直接把列表页第一页复制成首页的,这样就会出现两个相同的页面,我们这里介绍如何去除列表页第一页.
这里特别提醒大家,修改之前,请做好备份.
第一步:删除重复的类似list_1_1.html这个文件,打开 /include/arc.listview.class.php,搜索以下代码:
copy($list_1,$indexname);
在这行代码下面加上:
unlink($list_1);
这样就在生成html的时候自动将列表第一页删除.
第二步:将所有的分页第一页和首页链接指向首页,找到以下代码:
$tnamerule = ereg_replace('^(.*)/','',$tnamerule);
在下面加上:
if($this->Fields['ispart']==0&$this->Fields['defaultname']=="index.htm")
{
$tnamerule1 =$this->GetMakeFileRule($this->Fields['id'],"index",$this->Fields['typedir'],$this->Fields['defaultname'],$this->Fields['namerule2']);
$tnamerule1 = str_replace('index.htm','',$tnamerule1);
$tnamerule2 = ereg_replace('^(.*)/','index.htm',$tnamerule1);
}elseif($this->Fields['ispart']==0&$this->Fields['defaultname']=="index.html")
{
$tnamerule1 =$this->GetMakeFileRule($this->Fields['id'],"index",$this->Fields['typedir'],$this->Fields['defaultname'],$this->Fields['namerule2']);
$tnamerule1 = str_replace('index.html','',$tnamerule1);
$tnamerule2 = ereg_replace('^(.*)/','index.html',$tnamerule1);
}
else
{
$tnamerule1 =$this->GetMakeFileRule($this->Fields['id'],"index",$this->Fields['typedir'],$this->Fields['defaultname'],$this->Fields['namerule2']);
$tnamerule2 = ereg_replace('^(.*)/','',$tnamerule1);
}
{
$tnamerule1 =$this->GetMakeFileRule($this->Fields['id'],"index",$this->Fields['typedir'],$this->Fields['defaultname'],$this->Fields['namerule2']);
$tnamerule1 = str_replace('index.htm','',$tnamerule1);
$tnamerule2 = ereg_replace('^(.*)/','index.htm',$tnamerule1);
}elseif($this->Fields['ispart']==0&$this->Fields['defaultname']=="index.html")
{
$tnamerule1 =$this->GetMakeFileRule($this->Fields['id'],"index",$this->Fields['typedir'],$this->Fields['defaultname'],$this->Fields['namerule2']);
$tnamerule1 = str_replace('index.html','',$tnamerule1);
$tnamerule2 = ereg_replace('^(.*)/','index.html',$tnamerule1);
}
else
{
$tnamerule1 =$this->GetMakeFileRule($this->Fields['id'],"index",$this->Fields['typedir'],$this->Fields['defaultname'],$this->Fields['namerule2']);
$tnamerule2 = ereg_replace('^(.*)/','',$tnamerule1);
}
找到【 //获得上一页和主页的链接 】和【 //下一页,未页的链接 】,将中间的代码替换为以下代码:
if($this->PageNo != 1)
{
if($prepagenum==1)
{
$prepage.="<li><a href='".$tnamerule1."'>上一页</a></li>\r\n";
}
else
{
$prepage.="<li><a href='".str_replace("{page}",$prepagenum,$tnamerule)."'>上一页</a></li>\r\n";
}
$indexpage="<li><a href='".str_replace("{page}",1,$tnamerule1)."'>首页</a></li>\r\n";
}
{
if($prepagenum==1)
{
$prepage.="<li><a href='".$tnamerule1."'>上一页</a></li>\r\n";
}
else
{
$prepage.="<li><a href='".str_replace("{page}",$prepagenum,$tnamerule)."'>上一页</a></li>\r\n";
}
$indexpage="<li><a href='".str_replace("{page}",1,$tnamerule1)."'>首页</a></li>\r\n";
}
找到【 //option链接】和【 //获得数字链接】,将中间的代码替换为以下代码:
$optionlist = '';
$optionlen = strlen($totalpage);
$optionlen = $optionlen*12 + 18;
if($optionlen < 36) $optionlen = 36;
if($optionlen > 100) $optionlen = 100;
$optionlist = "<li><select name='sldd' style='width:{$optionlen}px' onchange='location.href=this.options[this.selectedIndex].value;'>\r\n";
for($mjj=1;$mjj<=$totalpage;$mjj++)
{
if($mjj==$this->PageNo)
{
$optionlist .= "<option value='".str_replace("{page}",$mjj,$tnamerule)."' selected>$mjj</option>\r\n";
}elseif($mjj==1)
{
$optionlist .= "<option value='".$tnamerule2."'>$mjj</option>\r\n";
}
else
{
$optionlist .= "<option value='".str_replace("{page}",$mjj,$tnamerule)."'>$mjj</option>\r\n";
}
}
$optionlist .= "</select></li>\r\n";
$optionlen = strlen($totalpage);
$optionlen = $optionlen*12 + 18;
if($optionlen < 36) $optionlen = 36;
if($optionlen > 100) $optionlen = 100;
$optionlist = "<li><select name='sldd' style='width:{$optionlen}px' onchange='location.href=this.options[this.selectedIndex].value;'>\r\n";
for($mjj=1;$mjj<=$totalpage;$mjj++)
{
if($mjj==$this->PageNo)
{
$optionlist .= "<option value='".str_replace("{page}",$mjj,$tnamerule)."' selected>$mjj</option>\r\n";
}elseif($mjj==1)
{
$optionlist .= "<option value='".$tnamerule2."'>$mjj</option>\r\n";
}
else
{
$optionlist .= "<option value='".str_replace("{page}",$mjj,$tnamerule)."'>$mjj</option>\r\n";
}
}
$optionlist .= "</select></li>\r\n";
找到以下代码:
if($j==$this->PageNo)
{
$listdd.= "<li class=\"thisclass\"><a>$j</a></li>\r\n";
}
{
$listdd.= "<li class=\"thisclass\"><a>$j</a></li>\r\n";
}
在下面加上以下代码:
elseif($j==1){
$listdd.="<li><a href='".str_replace("{page}",$j,$tnamerule1)."'>".$j."</a></li>\r\n";
}
$listdd.="<li><a href='".str_replace("{page}",$j,$tnamerule1)."'>".$j."</a></li>\r\n";
}
希望本文所述对大家的dedecms建站有所帮助。