织梦DedeCMS当前栏目高亮顶级栏目高亮

方法一 { dede : php } $GLOBALS [ thisid ] = intval ( $refObj - Fields [ id ] ) ; { / dede : php } ul li a href = / target = _blank { dede : php } if ( ! $GLOBALS [ thisid ] ) echo class=this ; { / dede : php } span HOME / span br / 首 页 […]



方法一

  1. {dede:php}$GLOBALS['thisid'] = intval($refObj->Fields['id']);{/dede:php} 
  2.     <ul>   
  3.      <li><a href="/" target="_blank"  {dede:php} if(!$GLOBALS['thisid']) echo "class='this'"; {/dede:php} ><span>HOMEspan><br />首 页a>li> 
  4.      {dede:channel type='top' row='7' }   
  5.      <li><a href="[field:typeurl/]" [field:id runphp='yes'] if (@me == $GLOBALS['thisid'] ) @me = "class='this' " ;[/field:id]  target="_blank" ><span>[field:alias/]span><br />[field:typename/]a>li> 
  6.     {/dede:channel} 
  7.     ul>

以上是全部代码。下面进行说明

  1. {dede:php}  $GLOBALS['thisid'] = intval($refObj->Fields['id']); {/dede:php}

获取当前栏目 ID。

  1. [field:id runphp='yes'] if (@me == $GLOBALS['thisid'] ) @me = "class='this' " ;[/field:id]

对 dede:channel 标签运行 PHP,如果 ID 相等,输出 class='this' 。

方法二

  1.     <a href="{dede:field.typeid runphp=yes}global $dsql;$row = $dsql->GetOne("SELECT * FROM #@_arctype WHERE id=@me");$reid = "$row[reid]"; $topid = "$row[topid]";if($reid == 0) @me = GetOneTypeUrlA($row);else $row = $dsql->GetOne("SELECT * FROM #@_arctype WHERE id=$topid");@me = GetOneTypeUrlA($row);{/dede:field.typeid}"{dede:field name=topid runphp=yes}if(@me)@me=''; else @me=' class="active"';{/dede:field}>全部
  2.  
  3.     {dede:channel type='son' currentstyle="~typename~"}
  4.     <a href='[field:typelink /]' title='[field:typename/]'>[field:typename/]a>
  5.     {/dede:channel}


加载中~