忆红颜 發表於 2023-7-9 00:00:00

dedecms 栏目列表分页链接优化

<p>
        <span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>DEDE默认栏目列表分页链接如: </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>&lt;li&gt;&lt;a href='list_4_1.html'&gt;首页&lt;/a&gt;&lt;/li&gt; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>&lt;li&gt;&lt;a href='list_4_3.html'&gt;上一页&lt;/a&gt;&lt;/li&gt; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>&lt;li&gt;&lt;a href='list_4_1.html'&gt;1&lt;/a&gt;&lt;/li&gt; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>&lt;li&gt;&lt;a href='list_4_2.html'&gt;2&lt;/a&gt;&lt;/li&gt; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>&lt;li&gt;&lt;a href='list_4_3.html'&gt;3&lt;/a&gt;&lt;/li&gt; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>&lt;li class="thisclass"&gt;4&lt;/li&gt; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>&lt;li&gt;&lt;a href='list_4_5.html'&gt;5&lt;/a&gt;&lt;/li&gt; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>&lt;li&gt;&lt;a href='list_4_5.html'&gt;下一页&lt;/a&gt;&lt;/li&gt; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>&lt;li&gt;&lt;a href='list_4_5.html'&gt;末页&lt;/a&gt;&lt;/li&gt; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>这种链接方式其实并不十分合理,比如这是http://www.abc.com/abc/这个栏目的列表分页链接,下面的链接方式才更合理: </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>&lt;li&gt;&lt;a href='/abc/'&gt;首页&lt;/a&gt;&lt;/li&gt; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>&lt;li&gt;&lt;a href='list_4_3.html'&gt;上一页&lt;/a&gt;&lt;/li&gt; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>&lt;li&gt;&lt;a href='/ab/'&gt;1&lt;/a&gt;&lt;/li&gt; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>&lt;li&gt;&lt;a href='list_4_2.html'&gt;2&lt;/a&gt;&lt;/li&gt;c </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>&lt;li&gt;&lt;a href='list_4_3.html'&gt;3&lt;/a&gt;&lt;/li&gt; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>&lt;li class="thisclass"&gt;4&lt;/li&gt; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>&lt;li&gt;&lt;a href='list_4_5.html'&gt;5&lt;/a&gt;&lt;/li&gt; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>&lt;li&gt;&lt;a href='list_4_5.html'&gt;下一页&lt;/a&gt;&lt;/li&gt; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>&lt;li&gt;&lt;a href='list_4_5.html'&gt;末页&lt;/a&gt;&lt;/li&gt; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>1.找到\include\arc.listview.class.php这个文件,将$typedir= ereg_replace('^(.*)/','',$this-&gt;Fields['typedir']);这种代码添加到“//获得上一页和主页的链接”前; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>2.找到$indexpage="&lt;li&gt;&lt;a href='".str_replace("{page}",1,$tnamerule)."'&gt;首页&lt;/a&gt;&lt;/li&gt;\r\n";将其改为$indexpage="&lt;li&gt;&lt;a href='/".$typedir."/'&gt;首页&lt;/a&gt;&lt;/li&gt;\r\n"; </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>3.找到$prepage.="&lt;li&gt;&lt;a href='".str_replace("{page}",$prepagenum,$tnamerule)."'&gt;上一页&lt;/a&gt;&lt;/li&gt;\r\n";改为: </span></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";'>
        <p class="right">
                <span><u>复制代码</u></span></p>
        <p>
                代码如下:</p>
</div>
<p class="msgborder" 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>
        if($prepagenum==1) <br>
        { <br>
        $prepage.="&lt;li&gt;&lt;a href='/".$typedir."/'&gt;上一页&lt;/a&gt;&lt;/li&gt;\r\n"; <br>
        } <br>
        else <br>
        { <br>
        $prepage.="&lt;li&gt;&lt;a href='".str_replace("{page}",$prepagenum,$tnamerule)."'&gt;上一页&lt;/a&gt;&lt;/li&gt;\r\n"; <br>
        } <br>
        4.找到$listdd.="&lt;li&gt;&lt;a href='".str_replace("{page}",$j,$tnamerule)."'&gt;".$j."&lt;/a&gt;&lt;/li&gt;\r\n";改为: <br>
        if($j==1) <br>
        { <br>
        $listdd.="&lt;li&gt;&lt;a href='/".$typedir."/'&gt;1&lt;/a&gt;&lt;/li&gt;\r\n"; <br>
        } <br>
        else <br>
        { <br>
        $listdd.="&lt;li&gt;&lt;a href='".str_replace("{page}",$j,$tnamerule)."'&gt;".$j."&lt;/a&gt;&lt;/li&gt;\r\n"; <br>
        } </p>
<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>
頁: [1]
查看完整版本: dedecms 栏目列表分页链接优化