<?PHP print_r(变量);?>
1.
<div class="webnav"> {pc:get sql="select catname,url from v9_category order by listorder ASC" } <ul class="clearfix"> <!--<li><a href="{siteurl($siteid)}">首页</a></li>--> {loop $data $r} <li><a href="{$r[url]}">{$r[catname]}</a></li> {/loop} </ul> {/pc} {PHP echo runhook('glogal_menu')} </div>
加粗的写法:从栏目表查出catname 和 url字段值 按照listorder 正序排列
{pc:get sql="select catname,url from v9_category order by listorder ASC" } 可以改写成
{pc:get sql="select*from v9_category order by listorder ASC" }
2.导航选中状态:
{if $catid == $r['catid']}class="current"{/if}
例如:
<div {pc:get sql="select * from v9_category order by listorder ASC"class="clearfix"> {$catid} <li><a href="{siteurl($siteid)}">首页</a></li>else} <li class="current"><a href="{siteurl( {/if} {loop } <li {$catid==if}><a href="{loop} </ul>pc} {PHP )} </div>
当然首页那也可以这样:
<li {if empty($catid)}if}><a href="{siteurl($siteid)}">首页</a></li>
$catid //当前栏目ID
$r['catid'] //循环出来的