登录  /  注册
首页 > php教程 > php手册 > 正文

dede channelartlist 中引用channel 并且设置当前选择类的样式,currentstyle暂时没有效果.特发求助!!!! - samcao

php中文网
发布: 2016-05-20 10:19:20
原创
1111人浏览过

在dede中需要达到当前选择了该类,样式不同的话.如果是channelartlist 的话. 可以使用下面的情况:

<span style="color: #008080;">1</span> {dede:channelartlist typeid='6' row='3' currentstyle='current'<span style="color: #000000;">}
</span><span style="color: #008080;">2</span>     
登录后复制
  • class='{dede:field.currentstyle/}'> 3 4 {dede:field name='typename'/} 5 6
  • 7 {/dede:channelartlist}

    这个默认没有效果.需要在channelartlist.lib.php中做下面的步骤:

    在这行的下面添加

    <span style="color: #008080;">1</span> <span style="color: #800080;">$pv</span>-&gt;Fields['typeurl'] = GetOneTypeUrlA(<span style="color: #800080;">$typeids</span>[<span style="color: #800080;">$i</span>]);
    登录后复制
    <span style="color: #008080;"> 1</span>         <span style="color: #008000;">#</span><span style="color: #008000;">#########################################################</span>
    <span style="color: #008080;"> 2</span>         
    <span style="color: #008080;"> 3</span>          <span style="color: #0000ff;">if</span>(<span style="color: #800080;">$typeids</span>[<span style="color: #800080;">$i</span>]['id'] == <span style="color: #800080;">$refObj</span>-&gt;TypeLink-&gt;TypeInfos['id'] || <span style="color: #800080;">$typeids</span>[<span style="color: #800080;">$i</span>]['id'] == <span style="color: #800080;">$refObj</span>-&gt;TypeLink-&gt;TypeInfos['topid'<span style="color: #000000;">] ){ 
    </span><span style="color: #008080;"> 4</span>             <span style="color: #800080;">$pv</span>-&gt;Fields['currentstyle'] = <span style="color: #800080;">$currentstyle</span> ? <span style="color: #800080;">$currentstyle</span> : 'current'<span style="color: #000000;">; 
    </span><span style="color: #008080;"> 5</span> <span style="color: #000000;">        } 
    </span><span style="color: #008080;"> 6</span>         <span style="color: #0000ff;">else</span><span style="color: #000000;">{ 
    </span><span style="color: #008080;"> 7</span>             <span style="color: #800080;">$pv</span>-&gt;Fields['currentstyle'] = ''<span style="color: #000000;">; 
    </span><span style="color: #008080;"> 8</span> <span style="color: #000000;">        } 
    </span><span style="color: #008080;"> 9</span>         
    <span style="color: #008080;">10</span>         <span style="color: #008000;">#</span><span style="color: #008000;">##########################################################</span>
    登录后复制

    添加上面的代码才可以.

     如果只是使用channel的话. 可以使用下面来实现. 在此引用 "元曦" 的图. 也谢谢"元曦"的帮助.

     

     
    但是.如果两个套一起. 就实现不了.以下帖上我的代码.
     
    <span style="color: #008080;"> 1</span> {dede:channelartlist typeid='6' row='3' currentstyle='current'<span style="color: #000000;">}
    </span><span style="color: #008080;"> 2</span>     
    登录后复制
  • class='{dede:field.currentstyle/}'> 3 4 {dede:field name='typename'/} 5 6
      class="faq_ul2"> 7 {dede:channel type='son' noself='yes' currentstyle=" 8
    • 9 >~typename~ 10
  • 11 "} 12
  • 13 --[field:typename/] 14
  • 15 {/dede:channel} 16 17 18 {/dede:channelartlist}

     

    这样channelartlist 会有class的样式. 但是内部 channel 并不会有class="testclass" ,甚是不解。

    于是决定至底层的php文件中查看一下。在channel.lib.php中输出测试一下。

     

    <span style="color: #008080;"> 1</span>                 <span style="color: #008000;">//</span><span style="color: #008000;">处理同级栏目中,当前栏目的样式</span>
    <span style="color: #008080;"> 2</span>                 <span style="color: #0000ff;">if</span>( (<span style="color: #800080;">$row</span>['id']==<span style="color: #800080;">$typeid</span> || (<span style="color: #800080;">$topid</span>==<span style="color: #800080;">$row</span>['id'] &amp;&amp; <span style="color: #800080;">$type</span>=='top') ) &amp;&amp; <span style="color: #800080;">$currentstyle</span>!=''<span style="color: #000000;"> )
    </span><span style="color: #008080;"> 3</span> <span style="color: #000000;">                {
    </span><span style="color: #008080;"> 4</span>                     <span style="color: #0000ff;">print</span> 'test_4';  <span style="color: #008000;">//</span><span style="color: #008000;">测试输出</span>
    <span style="color: #008080;"> 5</span>                     <span style="color: #800080;">$linkOkstr</span> = <span style="color: #800080;">$currentstyle</span><span style="color: #000000;">;
    </span><span style="color: #008080;"> 6</span>                     <span style="color: #800080;">$row</span>['typelink'] = GetOneTypeUrlA(<span style="color: #800080;">$row</span><span style="color: #000000;">);
    </span><span style="color: #008080;"> 7</span>                     <span style="color: #800080;">$linkOkstr</span> = <span style="color: #008080;">str_replace</span>("~rel~",<span style="color: #800080;">$row</span>['rel'],<span style="color: #800080;">$linkOkstr</span><span style="color: #000000;">);
    </span><span style="color: #008080;"> 8</span>                     <span style="color: #800080;">$linkOkstr</span> = <span style="color: #008080;">str_replace</span>("~id~",<span style="color: #800080;">$row</span>['id'],<span style="color: #800080;">$linkOkstr</span><span style="color: #000000;">);
    </span><span style="color: #008080;"> 9</span>                     <span style="color: #800080;">$linkOkstr</span> = <span style="color: #008080;">str_replace</span>("~typelink~",<span style="color: #800080;">$row</span>['typelink'],<span style="color: #800080;">$linkOkstr</span><span style="color: #000000;">);
    </span><span style="color: #008080;">10</span>                     <span style="color: #800080;">$linkOkstr</span> = <span style="color: #008080;">str_replace</span>("~typename~",<span style="color: #800080;">$row</span>['typename'],<span style="color: #800080;">$linkOkstr</span><span style="color: #000000;">);
    </span><span style="color: #008080;">11</span>                     <span style="color: #800080;">$likeType</span> .= <span style="color: #800080;">$linkOkstr</span><span style="color: #000000;">;
    </span><span style="color: #008080;">12</span> <span style="color: #000000;">                }
    </span><span style="color: #008080;">13</span>                 <span style="color: #0000ff;">else</span>
    <span style="color: #008080;">14</span> <span style="color: #000000;">                {
    </span><span style="color: #008080;">15</span>                     <span style="color: #0000ff;">print</span> 'test_5'; <span style="color: #008000;">//</span><span style="color: #008000;">测试输出</span>
    <span style="color: #008080;">16</span>                     <span style="color: #800080;">$row</span>['typelink'] = <span style="color: #800080;">$row</span>['typeurl'] = GetOneTypeUrlA(<span style="color: #800080;">$row</span><span style="color: #000000;">);
    </span><span style="color: #008080;">17</span>                     <span style="color: #0000ff;">if</span>(<span style="color: #008080;">is_array</span>(<span style="color: #800080;">$dtp2</span>-&gt;<span style="color: #000000;">CTags))
    </span><span style="color: #008080;">18</span> <span style="color: #000000;">                    {
    </span><span style="color: #008080;">19</span>                         <span style="color: #0000ff;">foreach</span>(<span style="color: #800080;">$dtp2</span>-&gt;CTags <span style="color: #0000ff;">as</span> <span style="color: #800080;">$tagid</span>=&gt;<span style="color: #800080;">$ctag</span><span style="color: #000000;">)
    </span><span style="color: #008080;">20</span> <span style="color: #000000;">                        {
    </span><span style="color: #008080;">21</span>                             <span style="color: #0000ff;">if</span>(<span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$row</span>[<span style="color: #800080;">$ctag</span>-&gt;GetName()])) <span style="color: #800080;">$dtp2</span>-&gt;Assign(<span style="color: #800080;">$tagid</span>,<span style="color: #800080;">$row</span>[<span style="color: #800080;">$ctag</span>-&gt;<span style="color: #000000;">GetName()]);
    </span><span style="color: #008080;">22</span> <span style="color: #000000;">                        }
    </span><span style="color: #008080;">23</span> <span style="color: #000000;">                    }
    </span><span style="color: #008080;">24</span>                     <span style="color: #800080;">$likeType</span> .= <span style="color: #800080;">$dtp2</span>-&gt;<span style="color: #000000;">GetResult();
    </span><span style="color: #008080;">25</span>                     
    <span style="color: #008080;">26</span>                 }
    登录后复制

     

    看是输出的test_5. 不解. 暂做记录.也希望大家给上上课.

     

    不要单个效果的.已经实现 .或者小弟那里有理解不对的地方. 请指出.

    主要是需要

    11111111111111111

          1-2

          1-3

    22222222222222222
          2-1
          2-2
    如果上面有选择2-1的时候.2-1的样式发生变化 .
     
     

     

    智能AI问答
    PHP中文网智能助手能迅速回答你的编程问题,提供实时的代码和解决方案,帮助你解决各种难题。不仅如此,它还能提供编程资源和学习指导,帮助你快速提升编程技能。无论你是初学者还是专业人士,AI智能助手都能成为你的可靠助手,助力你在编程领域取得更大的成就。
    来源:php中文网
    本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
    最新问题
    热门教程
    更多>
    最新下载
    更多>
    网站特效
    网站源码
    网站素材
    前端模板
    关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
    php中文网:公益在线php培训,帮助PHP学习者快速成长!
    关注服务号 技术交流群
    PHP中文网订阅号
    每天精选资源文章推送
    PHP中文网APP
    随时随地碎片化学习
    PHP中文网抖音号
    发现有趣的

    Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号