幸福蒙蒙 發表於 2024-6-15 00:00:00

dede currentstyle属性完美解决方案

<p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><strong>问题一、dede让channelartlist标签支持currentstyle属性 完美解决</strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        打开include\taglib\channelartlist.lib.php</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        找到</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><pre class="brush:php;toolbar:false;">$pv-&gt;Fields[&#39;typeurl&#39;]&nbsp;=&nbsp;GetOneTypeUrlA($typeids[$i]);</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        在此行代码下方增加以下代码:</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><pre class="brush:php;toolbar:false;">if($typeids[$i][&#39;id&#39;]&nbsp;==&nbsp;$refObj-&gt;TypeLink-&gt;TypeInfos[&#39;id&#39;]&nbsp;||&nbsp;$typeids[$i][&#39;id&#39;]&nbsp;==&nbsp;$refObj-&gt;TypeLink-&gt;TypeInfos[&#39;topid&#39;]&nbsp;){
$pv-&gt;Fields[&#39;currentstyle&#39;]&nbsp;=&nbsp;$currentstyle&nbsp;?&nbsp;$currentstyle&nbsp;:&nbsp;&#39;current&#39;;
}
else{
$pv-&gt;Fields[&#39;currentstyle&#39;]&nbsp;=&nbsp;&#39;&#39;;
}</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        网上找到的一般没有加$typeids[$i][&#39;id&#39;] ==$refObj-&gt;TypeLink-&gt;TypeInfos[&#39;topid&#39;]</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        添加这个后才能对二级栏目也起作用</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        调用方法:</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><pre class="brush:php;toolbar:false;">{dede:channelartlist&nbsp;typeid=&#39;2&#39;&nbsp;currentstyle=&#39;current&#39;}{dede:field&nbsp;name=&#39;typename&#39;/}。。。
{/dede:channelartlist}</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        如果是当前栏目则 li的class属性显示current,否则显示class=&#39;&#39; ,也可以修改currentstyle=&#39;这里改为你需要的类名&#39;。</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        也可以与arclist标签相结合使用,</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        这样调用:</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><pre class="brush:php;toolbar:false;">{dede:channelartlist&nbsp;typeid=&#39;2&#39;&nbsp;currentstyle=&#39;current&#39;}{dede:field&nbsp;name=&#39;typename&#39;/}{dede:arclist&nbsp;titlelen=&#39;42&#39;&nbsp;row=&#39;10&#39;&nbsp;current}

if(@me[&#39;currentstyle&#39;]){
@me&nbsp;=&nbsp;@me[&#39;currentstyle&#39;];
}else{
@me&nbsp;=&nbsp;&quot;{@me[&#39;title&#39;]}&quot;;
}

{/dede:arclist}
{/dede:channelartlist}</pre></div><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><strong>问题二、织梦channel标签currentstyle样式无效不起作用</strong></p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        我们在用织梦系统制作网站时,经常会用到channel标签来调子栏目。但是,很多朋友会遇到这种情况在使用channel标签来调子栏目的时候,指定 “type=son typeid=x” 发现currentstyle无效。今天笔者就跟大家分享一下解决方法。</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        1、解决channel标签currentstyle样式无效不起作用的错误方法</p><p style="margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;">
        代码如下:</p><div class="jb51code" style="margin: 0px; padding: 0px; outline: none; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma, arial, &quot;Microsoft YaHei&quot;;"><pre class="brush:php;toolbar:false;">{dede:&nbsp;type=&#39;son&#39;&nbsp;typeid=&#39;12&#39;&nbsp;currentMicrosoft&nbsp;YaHei&quot;;&#39;&gt;
        解决的办法:把typeid=‘12’改为channel=‘1’&nbsp;(文章模型id),首页除外,其他页面不需要指定typeid=x,会自动判断当前位置。
        解决方法如下:{dede:&nbsp;type=&#39;son&#39;&nbsp;channel=&#39;1&#39;&nbsp;currentmargin:&nbsp;0px;&nbsp;padding:&nbsp;0px;&nbsp;outline:&nbsp;none;&nbsp;line-height:&nbsp;25.2px;&nbsp;font-size:&nbsp;14px;&nbsp;width:&nbsp;660px;&nbsp;overflow:&nbsp;hidden;&nbsp;clear:&nbsp;both;&nbsp;font-family:&nbsp;tahoma,&nbsp;arial,&nbsp;&quot;Microsoft&nbsp;YaHei&quot;;&quot;&gt;if(&nbsp;($row[&#39;id&#39;]==$typeid&nbsp;||&nbsp;($topid==$row[&#39;id&#39;]&nbsp;&amp;&amp;&nbsp;$type==&#39;top&#39;)&nbsp;)&nbsp;&amp;&amp;&nbsp;$currentstyle!=&#39;&#39;&nbsp;)
        改成if(&nbsp;(&nbsp;$row[&#39;id&#39;]==&nbsp;$refObj-&gt;TypeLink-&gt;TypeInfos[&#39;id&#39;]&nbsp;||&nbsp;($topid==$row[&#39;id&#39;]&nbsp;&amp;&amp;&nbsp;$type==&#39;top&#39;)&nbsp;)&nbsp;&amp;&amp;&nbsp;$currentstyle!=&#39;&#39;&nbsp;)
        笔者经测试这种调用方式currentstyle有效,可以解决解决channel标签currentstyle样式无效不起作用的问题。
        以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。</pre></div>
頁: [1]
查看完整版本: dede currentstyle属性完美解决方案