zblogPHP主題制作中,常遇到調(diào)用網(wǎng)站分類的情況,比如常用在下拉菜單中。
首先,zblog模板中的網(wǎng)站分類默認調(diào)用為:
{module:catalog}
如果要對嵌套的LU LI增加CSS,對調(diào)取代碼進行DIY就需要下方這段調(diào)用代碼:
function yunduan_catalogleft() { global $zbp; $s = ''; if ($zbp->option['ZC_MODULE_CATALOG_STYLE'] == '2') { foreach ($zbp->categorysbyorder as $key => $value) { if ($value->Level == 0) { $s .= '<li id="navbar-category-'.$value->ID.'" class="submenu li-cate-'.$value->ID.'"><a href="' . $value->Url . '"><i class="icon-right-dir"></i> ' . $value->Name . '</a><!--' . $value->ID . 'begin--><!--' . $value->ID . 'end--></li>'; } } foreach ($zbp->categorysbyorder as $key => $value) { if ($value->Level == 1) { $s = str_replace('<!--' . $value->ParentID . 'end-->', '<li id="navbar-category-'.$value->ID.'" class="li-subcate-'.$value->ID.'"><a href="' . $value->Url . '">' . $value->Name . '</a><!--' . $value->ID . 'begin--><!--' . $value->ID . 'end--></li><!--' . $value->ParentID . 'end-->', $s); } } foreach ($zbp->categorysbyorder as $key => $value){ if($value->Level == 2) { $s = str_replace('<!--' . $value->ParentID . 'end-->', '<li id="navbar-category-'.$value->ID.'" class="li-subcate-'.$value->ID.'"><a href="' . $value->Url . '">' . $value->Name . '</a><!--' . $value->ID . 'begin--><!--' . $value->ID . 'end--></li><!--' . $value->ParentID . 'end-->', $s); } }foreach($zbp->categorysbyorder as $key => $value){ if ($value->Level == 3) { $s = str_replace('<!--' . $value->ParentID . 'end-->', '<li id="navbar-category-'.$value->ID.'" class="li-subcate-'.$value->ID.'"><a href="' . $value->Url . '">' . $value->Name . '</a><!--' . $value->ID . 'begin--><!--' . $value->ID . 'end--></li><!--' . $value->ParentID . 'end-->', $s); } }foreach($zbp->categorysbyorder as $key => $value){ $s = str_replace('<!--' . $value->ID . 'begin--><!--' . $value->ID . 'end-->', '', $s); }foreach($zbp->categorysbyorder as $key => $value){ $s = str_replace('<!--' . $value->ID . 'begin-->', '<ul class="sub-menu">', $s); $s = str_replace('<!--' . $value->ID . 'end-->', '</ul>', $s); } }elseif($zbp->option['ZC_MODULE_CATALOG_STYLE'] == '1'){ foreach ($zbp->categorysbyorder as $key => $value){ $s .= '<li id="navbar-category-'.$value->ID.'">' . $value->Symbol . '<a href="' . $value->Url . '">' . $value->Name . '</a></li>'; } }else{ foreach ($zbp->categorysbyorder as $key => $value){ $s .= '<li id="navbar-category-'.$value->ID.'"><a href="' . $value->Url . '">' . $value->Name . '</a></li>'; } }return $s; }
最簡單的調(diào)用方法:
{yunduan_catalogleft()}