好芒手工炒酸奶 發表於 2024-3-23 00:00:00

织梦DedeCMS在实现中英文导航功能方法步骤

<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        今天在群里看到有位朋友需要实现中英文栏目名字的功能(如下图),下面我们就来看看强大的织梦CMS怎么实现吧!</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        <img style="max-width:100%!important;height:auto!important;"title="织梦DedeCMS在实现中英文导航功能方法步骤" alt="织梦DedeCMS在实现中英文导航功能方法步骤" src="https://zhuji.jb51.net/uploads/img/202305/1f51fe3a51c4fc83d9f31a06544ca077.jpg"></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        首先给数据库中的dede_arctype表中增加一个字段,前面的表前缀是你的站点的名,并不一定是dede_</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        <img style="max-width:100%!important;height:auto!important;"title="织梦DedeCMS在实现中英文导航功能方法步骤" alt="织梦DedeCMS在实现中英文导航功能方法步骤" src="https://zhuji.jb51.net/uploads/img/202305/13006652df8b4a25a93084c1eb47311c.jpg"></p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        添加后的效果如上图,具体的添加办法再次就不详述了。其中typenameng就是我增加的字段,名称有点长,当然你也可以改为自己乐意的名称,这个不伤大雅。<br>
        再找到dede\templets目录下的catalog_edit.htm<br>
         <br>
        找到</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>
        代码如下:</div>
<div class="msgborder" id="phpcode8" 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;tr&gt;<br>
        &lt;td class='bline' height="26"&gt;&lt;font color='red'&gt;栏目名称:&lt;/font&gt;&lt;/td&gt;<br>
        &lt;td class='bline'&gt;&lt;input name="typename" type="text" id="typename" size="30" value="&lt;?php echo $myrow['typename']?&gt;" class="iptxt" /&gt;&lt;/td&gt;<br>
        &lt;/tr&gt;</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";'>
        下面添加<br>
         <br>
         </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>
        代码如下:</div>
<div class="msgborder" id="phpcode9" 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;tr&gt;<br>
        &lt;td class='bline' height="26"&gt;栏目英文名称:&lt;/td&gt;<br>
        &lt;td class='bline'&gt;&lt;input name="typenameng" type="text" id="typenameng" size="30" value="&lt;?php echo $myrow['typenameng']?&gt;" class="iptxt" /&gt;&lt;/td&gt;<br>
        &lt;/tr&gt;</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";'>
        最后我们在打开 dede\catalog_edit.php<br>
         <br>
         <br>
        找到<br>
         </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>
        代码如下:</div>
<div class="msgborder" id="phpcode10" 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>
        $upquery = "UPDATE `#分隔符@__arctype` SET<br>
        issend='$issend',<br>
        sortrank='$sortrank',<br>
        typename='$typename',<br>
        typenameng='$typenameng',<br>
        typedir='$typedir',<br>
        isdefault='$isdefault',<br>
        defaultname='$defaultname',</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";'>
        增加红色的部分,分隔符3个字自行去掉,至此就添加完成了。<br>
         <br>
        调用方式 :{dede:field name='typenameng'/}<br>
         <br>
         <br>
        想要在channel 中使用,例如<br>
         </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>
        代码如下:</div>
<div class="msgborder" id="phpcode11" 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>
        {dede:channel type='son' row='10' typeid='1'}<br>
        &lt;li&gt;&lt;a href=''&gt;&lt;/a&gt;&lt;/li&gt;<br>
        {/dede:channel}</div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>则还要修改一个文件,找到include\taglib\channel.lib.php</span><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;'>第一处:</span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><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>
        代码如下:</div>
<div class="msgborder" id="phpcode12" 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($type=='top')<br>
        {<br>
        $sql = "SELECT id,typename,typenameng,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath<br>
        From `#分隔符@__arctype` WHERE reid=0 And ishidden&lt;&gt;1 order by sortrank asc limit 0, $line ";<br>
        }<br>
        else if($type=='son')<br>
        {<br>
        if($typeid==0) return '';<br>
        $sql = "SELECT id,typename,typenameng,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath<br>
        From `#分隔符@__arctype` WHERE reid='$typeid' And ishidden&lt;&gt;1 order by sortrank asc limit 0, $line ";<br>
        }<br>
        else if($type=='self')<br>
        {<br>
        if($reid==0) return '';<br>
        $sql = "SELECT id,typename,typenameng,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath<br>
        FROM `#分隔符@__arctype` WHERE reid='$reid' And ishidden&lt;&gt;1 order by sortrank asc limit 0, $line ";<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";'>
        第二处:<br>
         </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>
        代码如下:</div>
<div class="msgborder" id="phpcode13" 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>
        if($type=='son' &amp;&amp; $reid!=0 &amp;&amp; $totalRow==0)<br>
        {<br>
        $sql = "SELECT id,typename,typenameng,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath<br>
        FROM `#分隔符@__arctype` WHERE reid='$reid' And ishidden&lt;&gt;1 order by sortrank asc limit 0, $line ";<br>
        $dsql-&gt;SetQuery($sql);<br>
        $dsql-&gt;Execute();<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";'>
        增加查询字段就可以在channel中使用了,还有type,channelartlist等标签页是在相应的lib类中添加查询的字段,在此限于篇幅就不错详细的叙述了。<br>
         <br>
        //处理同级栏目中,当前栏目的样式。currentstyle中的调用,include\taglib\channel.lib.php 140行 $linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr);下面添加<br>
        $linkOkstr = str_replace("~typenameeng~",$row['typenameeng'],$linkOkstr);即可。</p>
頁: [1]
查看完整版本: 织梦DedeCMS在实现中英文导航功能方法步骤