一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

织梦dedecms5.7中tags标签伪静态配置教程

时间:2016-07-27 编辑:简简单单 来源:一聚教程网

关于tags伪静态配置比其它的配置要简单的多了只需要修改几个小地方即可实现。

DedeCms默认的TAG标签URL,形如/tags.php?/dedecms模板 /,是不是觉得有个问号不怎么爽,我们改

成/tags/dedecms模板 /,是不是好看多了。


下面我们来改一下,打开/include/taglib/tag.lib.php:

 代码如下 复制代码

查找:

$row['link'] = $cfg_cmsurl."/tags.php?/".urlencode($row['keyword'])."/";

替换为

$row['link'] = $cfg_cmsurl."/tags/".urlencode($row['keyword'])."/";

如果有分页的话需要对分页进行处理

修改include/arc.taglist.class.php,找到分页函数,将其更换为:
  注意:从429行  ---->541行  用以下内容替换!
  (提示:网上有文章中讲的以下代码中的"pageinfo"是错误的,应该为\"pageinfo\",不然会有错误提示哦!已经代码测试OK!)

 代码如下 复制代码

/** * 获取动态的分页列表
*
* @access public
* @param int $list_len 列表宽度
* @param string $listitem 列表样式
* @return string
*/
function GetPageListDM($list_len,$listitem="info,index,end,pre,next,pageno")
{
$prepage="";
$nextpage="";
$prepagenum = $this->PageNo - 1;
$nextpagenum = $this->PageNo + 1;
if($list_len == "" || preg_match("/[^0-9]/", $list_len))
{
$list_len = 3;
}
$totalpage = $this->TotalPage;
if($totalpage <= 1 && $this->TotalResult > 0)
{
return "共1页/".$this->TotalResult."条";
}
if($this->TotalResult == 0)
{
return "共0页/".$this->TotalResult."条";
}
$maininfo = "共{$totalpage}页/".$this->TotalResult."条rn";
$purl = $this->GetCurUrl();
$basename = basename($purl);
$tmpname = explode('.', $basename);

$purl = str_replace($basename, '', $purl).urlencode($this->Tag);
//var_dump($purl);exit;
//$purl .= "?/".urlencode($this->Tag);

//获得上一页和下一页的链接
if($this->PageNo != 1)
{
$prepage.="

  • 上一页
  • rn";
    $indexpage="
  • 首页
  • rn";
    }
    else
    {
    $indexpage="
  • 首页
  • rn";
    }
    if($this->PageNo!=$totalpage && $totalpage>1)
    {
    $nextpage.="
  • 下一页
  • rn";
    $endpage="
  • 末页
  • rn";
    }
    else
    {
    $endpage="
  • 末页
  • rn";
    }

    //获得数字链接
    $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.= "

  • $j
  • rn";
    }
    else
    {
    $listdd.="
  • ".$j."
  • rn";
    }
    }
    $plist = '';
    if(preg_match('/info/i', $listitem))
    {
    $plist .= $maininfo.' ';
    }
    if(preg_match('/index/i', $listitem))
    {
    $plist .= $indexpage.' ';
    }
    if(preg_match('/pre/i', $listitem))
    {
    $plist .= $prepage.' ';
    }
    if(preg_match('/pageno/i', $listitem))
    {
    $plist .= $listdd.' ';
    }
    if(preg_match('/next/i', $listitem))
    {
    $plist .= $nextpage.' ';
    }
    if(preg_match('/end/i', $listitem))
    {
    $plist .= $endpage.' ';
    }
    return $plist;
    }

    .htaccess或者apache配置

     代码如下 复制代码

    RewriteRule ^(.*)/tags\.html $1/tags\.php [I]
    RewriteRule ^(.*)/tags/(.*)(?:(\?.*))* $1/tags\.php\?\/$2 [I]
    RewriteRule ^(.*)/tags/(.*)\/(?:(\?.*))* $1/tags\.php\?\/$2\/ [I]

    热门栏目