1、頭部模版代碼
<div class="nav" id="nav">
<ul>
<li id="index" class="{$=#ngenre}"><a href="{$=ii_get_actual_route('./')}"><span class="font1">首 頁</span><br />
<span class="font2"> Home</span></a></li>
<li id="photo" class="{$=#ngenre}"><a href="{$=ii_get_actual_route('photo')}"><span class="font1">攝影作品</span><br />
<span class="font2">Photography</span></a></li>
<li id="model" class="{$=#ngenre}"><a href="{$=ii_get_actual_route('model')}"><span class="font1">模特資料</span><br />
<span class="font2">Model Data</span></a></li>
</ul>
</div>
{$=#ngenre}獲取模塊名,把導(dǎo)航菜單項(xiàng)目,按照對(duì)應(yīng)的模塊名稱id命名,方便通過js對(duì)對(duì)應(yīng)的id的菜單項(xiàng)目增加on
2、首頁模版添加
<script type="text/javascript">document.getElementById("index").className = "on";</script>
3、列表頁模版添加
<!-- top menu hover -->
<script type="text/javascript">document.getElementById("{$=#ngenre}").className = "on";</script>
<!-- side menu hover -->
<script type="text/javascript">document.getElementById("{$=$ngenre}{$classid}").className = "on";</script>
{$classid}獲取動(dòng)態(tài)分類id
4、內(nèi)容頁模版添加
<!-- top menu hover -->
<script type="text/javascript">document.getElementById("{$=#ngenre}").className = "on";</script>
<!-- side menu hover -->
<script type="text/javascript">document.getElementById("{$class}").className = "on";</script>
程序去獲取文章詳情頁的文章所在分類ID,然后給菜單有這個(gè)ID的菜單項(xiàng)目增加一個(gè)class=on
5、sort分類調(diào)用節(jié)點(diǎn)
<li id="{$id}">
獲取動(dòng)態(tài)id數(shù)字
6、css文件添加樣式
.nav2 ul .on > a{ color:#ad223f!important; }
.nav .on a { background:#af2242; }
子元素功能 li>a 故名 on > a
隨便記錄下.net版本JS代碼
<!-- top menu hover -->
<script type="text/javascript">document.getElementById("{$=$ngenre}").className = "on";</script>
<!-- side menu hover -->
<script type="text/javascript">document.getElementById("{$=$ngenre}{$-class}").className = "on";</script>