鹤发童心 發表於 2023-10-7 00:00:00

DedeCMS 5.7系统TAG标签伪静态设置

<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        <strong>1.修改前台显示链接</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        我们这里达到的效果就是使原来/tags.php?keywors更改为/tags/keywords.html。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        这里主要修改下调用的标签,在include/tag/libtag.lib.php中,在87行找到</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode26" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        $row['link'] = $cfg_cmsurl."/tags?".urlencode($row['keyword']);</div>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>将其改为:</span></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode27" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        $row['link'] = $cfg_cmsurl."/tags/".urlencode($row['keyword']).".html";</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        <strong>2.修改分页代码</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        我们需要修改include/arc.taglist.class.php,将分页函数替换为:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode28" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        /** * 获取动态的分页列表<br>
        *<br>
        * @access public<br>
        * @param int $list_len 列表宽度<br>
        * @param string $listitem 列表样式<br>
        * @return string<br>
        */<br>
        function GetPageListDM($list_len,$listitem="info,index,end,pre,next,pageno")<br>
        {<br>
        $prepage="";<br>
        $nextpage="";<br>
        $prepagenum = $this-&gt;PageNo - 1;<br>
        $nextpagenum = $this-&gt;PageNo + 1;<br>
        if($list_len == "" || preg_match("/[^0-9]/", $list_len))<br>
        {<br>
        $list_len = 3;<br>
        }<br>
        $totalpage = $this-&gt;TotalPage;<br>
        if($totalpage &lt;= 1 &amp;&amp; $this-&gt;TotalResult &gt; 0)<br>
        {<br>
        return "&lt;span class="pageinfo"&gt;共1页/".$this-&gt;TotalResult."条&lt;/span&gt;";<br>
        }<br>
        if($this-&gt;TotalResult == 0)<br>
        {<br>
        return "&lt;span class="pageinfo"&gt;共0页/".$this-&gt;TotalResult."条&lt;/span&gt;";<br>
        }<br>
        $maininfo = "&lt;span class="pageinfo"&gt;共{$totalpage}页/".$this-&gt;TotalResult."条&lt;/span&gt;rn";<br>
        $purl = $this-&gt;GetCurUrl();<br>
        $basename = basename($purl);<br>
        $tmpname = explode('.', $basename);<br><br>
        $purl = str_replace($basename, '', $purl).urlencode($this-&gt;Tag);<br>
        //var_dump($purl);exit;<br>
        //$purl .= "?/".urlencode($this-&gt;Tag);<br><br>
        //获得上一页和下一页的链接<br>
        if($this-&gt;PageNo != 1)<br>
        {<br>
        $prepage.="&lt;li&gt;&lt;a href='".$purl."-$prepagenum'.html&gt;上一页&lt;/a&gt;&lt;/li&gt;rn";<br>
        $indexpage="&lt;li&gt;&lt;a href='".$purl."-1.html'&gt;首页&lt;/a&gt;&lt;/li&gt;rn";<br>
        }<br>
        else<br>
        {<br>
        $indexpage="&lt;li&gt;&lt;a&gt;首页&lt;/a&gt;&lt;/li&gt;rn";<br>
        }<br>
        if($this-&gt;PageNo!=$totalpage &amp;&amp; $totalpage&gt;1)<br>
        {<br>
        $nextpage.="&lt;li&gt;&lt;a href='".$purl."-$nextpagenum.html'&gt;下一页&lt;/a&gt;&lt;/li&gt;rn";<br>
        $endpage="&lt;li&gt;&lt;a href='".$purl."-$totalpage.html'&gt;末页&lt;/a&gt;&lt;/li&gt;rn";<br>
        }<br>
        else<br>
        {<br>
        $endpage="&lt;li&gt;&lt;a&gt;末页&lt;/a&gt;&lt;/li&gt;rn";<br>
        }<br><br>
        //获得数字链接<br>
        $listdd="";<br>
        $total_list = $list_len * 2 + 1;<br>
        if($this-&gt;PageNo &gt;= $total_list)<br>
        {<br>
        $j = $this-&gt;PageNo - $list_len;<br>
        $total_list = $this-&gt;PageNo + $list_len;<br>
        if($total_list &gt; $totalpage)<br>
        {<br>
        $total_list = $totalpage;<br>
        }<br>
        }<br>
        else<br>
        {<br>
        $j=1;<br>
        if($total_list &gt; $totalpage)<br>
        {<br>
        $total_list = $totalpage;<br>
        }<br>
        }<br>
        for($j; $j&lt;=$total_list; $j++)<br>
        {<br>
        if($j == $this-&gt;PageNo)<br>
        {<br>
        $listdd.= "&lt;li class="thisclass"&gt;&lt;a&gt;$j&lt;/a&gt;&lt;/li&gt;rn";<br>
        }<br>
        else<br>
        {<br>
        $listdd.="&lt;li&gt;&lt;a href='".$purl."-$j.html'&gt;".$j."&lt;/a&gt;&lt;/li&gt;rn";<br>
        }<br>
        }<br>
        $plist = '';<br>
        if(preg_match('/info/i', $listitem))<br>
        {<br>
        $plist .= $maininfo.' ';<br>
        }<br>
        if(preg_match('/index/i', $listitem))<br>
        {<br>
        $plist .= $indexpage.' ';<br>
        }<br>
        if(preg_match('/pre/i', $listitem))<br>
        {<br>
        $plist .= $prepage.' ';<br>
        }<br>
        if(preg_match('/pageno/i', $listitem))<br>
        {<br>
        $plist .= $listdd.' ';<br>
        }<br>
        if(preg_match('/next/i', $listitem))<br>
        {<br>
        $plist .= $nextpage.' ';<br>
        }<br>
        if(preg_match('/end/i', $listitem))<br>
        {<br>
        $plist .= $endpage.' ';<br>
        }<br>
        return $plist;<br>
        }</div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        <strong>3.设置伪静态规则</strong></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        我们这里以iis7为例子,设置以下规则:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        <p>
                代码如下:</p>
</div>
<div class="msgborder" id="phpcode29" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        &lt;?xml version="1.0" encoding="UTF-8"?&gt;<br>
        &lt;configuration&gt;<br>
        &lt;system.webServer&gt;<br>
        &lt;rewrite&gt;<br>
        &lt;rules&gt;<br>
        &lt;rule name="weather1" stopProcessing="true"&gt;<br>
        &lt;match url="tags/([^-]+).html$" ignoreCase="true" /&gt;<br>
        &lt;conditions logicalGrouping="MatchAll"&gt;<br>
        &lt;add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /&gt;<br>
        &lt;add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /&gt;<br>
        &lt;/conditions&gt;<br>
        &lt;action type="Rewrite" url="/tags.php?/{R:1}" appendQueryString="false" /&gt;<br>
        &lt;/rule&gt;<br>
        &lt;rule name="weather2" stopProcessing="true"&gt;<br>
        &lt;match url="tags/([^-]+)-(+).html$" ignoreCase="true" /&gt;<br>
        &lt;conditions logicalGrouping="MatchAll"&gt;<br>
        &lt;add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /&gt;<br>
        &lt;add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /&gt;<br>
        &lt;/conditions&gt;<br>
        &lt;action type="Rewrite" url="/tags.php?/{R:1}/{R:2}" appendQueryString="false" /&gt;<br>
        &lt;/rule&gt;<br>
        &lt;/rules&gt;<br>
        &lt;/rewrite&gt;<br>
        &lt;/system.webServer&gt;<br>
        &lt;/configuration&gt;</div>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'> </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>可以直接保存为web.config放在站点根目录。</span></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
         </p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        <strong>4.重新生成html页面</strong><br><br>
        这个操作就不用说了,全部重新生成下,至此全部修改完毕。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        <strong>5.预览查看显示结果</strong><br><br>
        至此,我们已经完成了所有的设置,可以查看:http://www.**.net/tags/PHP.html语言效果。</p>
頁: [1]
查看完整版本: DedeCMS 5.7系统TAG标签伪静态设置