首页  »  站长资讯  »  网站优化

织梦用arclist标签设置当前文章高亮

2023/03/11 12:23     创新屋收录网     已浏览351次
做网站比如一些帮助、说明类的页面可以用栏目去做,也可以用文章来做,考虑用文章是因为文章写起来比较方便,还可以用自定义的字段,比栏目要灵活得多。栏目比较好处理当前栏目高亮的问题,写法如下

{dede:channel typeid='' row='' currentstyle="
  • ~typename~
  • "}

  • [field:title/]


  • {/dede:channel}

    注意typelink和typeurl的写法。如果用文章来做的话,就需要修改几个地方,网上有些错误的写法,笔者亲自测试过,修正后分享给大家。

    include/taglib/arclist.lib.php

            找到

    //增加对分页内容的处理

    在这段前加入

    $currentstyle = $ctag->GetAtt('currentstyle');

    在大概135行,找到

    $tagid,$pagesize,$isweight

            增加 ,$currentstyle  也就是

    $tagid,$pagesize,$isweight,$currentstyle

    大概在170行,找到

    $isweight='N'

            后面增加

    ,$currentstyle=''

    在519行,找到

    $row['textlink'] = "
    ".$row['title']."";

            后面增加

    //by织梦模板 www.80zhan.com

    if($currentstyle && $row['id']==$arcid){

    $currentstyle = str_replace('~typelink~', $row['filename'], $currentstyle);

    $row['currentstyle'] = str_replace('~typename~', $row['title'], $currentstyle);



    }

    模板调用,具体样式请自行修改

        {dede:arclist currentstyle="
  • ~typename~
  • "}

        [field:array runphp='yes']

         if(@me['currentstyle']){

          @me = @me['currentstyle'];

         }else{

          @me = "
  • {@me['title']}
  • ";

        }

        [/field:array]

        {/dede:arclist}