代码如下:

 

    <ul id="navigation">

        <li id="nav1"> <a href="/"><strong>网站首页</strong></a> </li>

        {dede:channel type='top' row='' currentstyle="

        <li id=nav~autoindex~> <a class='selected' href='~typelink~'><strong>~typename~</strong></a> </li>

        "}

        <li id="nav[field:global name=autoindex runphp="yes"]@me=@me+2;[/field:global]"> <a href="[field:typeurl /]"><strong>[field:typename /]</strong></a> </li>

        {/dede:channel}

      </ul>

 

 

  在include/taglib/channel.lib.php里找到下面的代码,大概在102行

 

  //处理同级栏目中,当前栏目的样式

 

  if( ($row['id']==$typeid || ($topid==$row['id'] && $type=='top') ) && $currentstyle!='' )

 

  {

 

  $linkOkstr = $currentstyle;

 

  $row['typelink'] = GetOneTypeUrlA($row);

 

  $linkOkstr = str_replace("~rel~",$row['rel'],$linkOkstr);

 

  $linkOkstr = str_replace("~id~",$row['id'],$linkOkstr);

 

  $linkOkstr = str_replace("~typelink~",$row['typelink'],$linkOkstr);

 

  $linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr);

 

  $likeType .= $linkOkstr;

 

  }

 

  看到没,这里就是 currentstyle支持的变量,总共有4个,但是没有一个是索引,不过没关系,我们很容易的就可以加一个

 

  在中间位置加入下面的代码

 

  $linkOkstr = str_replace("~autoindex~",$GLOBALS['autoindex']+2,$linkOkstr);

 

$GLOBALS['autoindex'] 加上几视自身情况而定,我这里需要从2开始

 

    //处理同级栏目中,当前栏目的样式

 

  if( ($row['id']==$typeid || ($topid==$row['id'] && $type=='top') ) && $currentstyle!='' )

 

  {

 

  $linkOkstr = $currentstyle;

 

  $row['typelink'] = GetOneTypeUrlA($row);

 

  $linkOkstr = str_replace("~rel~",$row['rel'],$linkOkstr);

 

  $linkOkstr = str_replace("~id~",$row['id'],$linkOkstr);

 

  $linkOkstr = str_replace("~autoindex~",$GLOBALS['autoindex']+2,$linkOkstr);

 

  $linkOkstr = str_replace("~typelink~",$row['typelink'],$linkOkstr);

 

  $linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr);

 

  $likeType .= $linkOkstr;

 

  }

 

  这样做好后,就可以在用 channel里用这个索引了

 

     <ul id="navigation">

        <li id="nav1"> <a href="/"><strong>网站首页</strong></a> </li>

        {dede:channel type='top' row='' currentstyle="

        <li id=nav~autoindex~> <a class='selected' href='~typelink~'><strong>~typename~</strong></a> </li>

        "}

        <li id="nav[field:global name=autoindex runphp="yes"]@me=@me+2;[/field:global]"> <a href="[field:typeurl /]"><strong>[field:typename /]</strong></a> </li>

        {/dede:channel}

      </ul>