zblogPHP主题制作中,常遇到调用网站分类的情况,比如常用在下拉菜单中。
首先,zblog模板中的网站分类默认调用为:
{module:catalog}
如果要对嵌套的LU LI增加CSS,对调取代码进行DIY就需要下方这段调用代码:
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; }
最简单的调用方法:
{yunduan_catalogleft()}