在使用易優(yōu)cms時(shí),遇到欄目頁(yè)或者內(nèi)容頁(yè)二級(jí)欄目導(dǎo)航和三級(jí)欄目導(dǎo)航分開(kāi)調(diào)用時(shí),標(biāo)簽如何調(diào)用呢?先在公用函數(shù)文件里加一截代碼,。
公用函數(shù)文件extend/function.php打開(kāi)后在底部添加下面代碼
/**
* 獲取頂級(jí)欄目下是否3級(jí),并輸出指定的字符
* 模板使用方法:{$field.typeid|diy_arctype_level=###,輸出的字符}
*/
function diy_arctype_level($typeid, $str = '')
{
$result = model('Arctype')->getHasChildren($typeid, true);
$max_level = 0;
$temp = [];
foreach ($result as $k => $v){
$temp[] = $v['level'];
}
!empty($temp) && $max_level= max($temp);
if (2 == $max_level) {
return $str;
} else {
return '';
}
}
然后下面時(shí)模板使用代碼,注意樣式文件自己修改
<div class="pagelinks">
<ul >
<!--獲取二級(jí)欄目開(kāi)始-->
{eyou:channel type="first" currentstyle="on" id='field'}
<!--有三級(jí)時(shí)判斷二級(jí)欄目高亮開(kāi)始-->
{eyou:eq name='$eyou.field.grade' value='2'}
{eyou:type typeid='$eyou.field.typeid' id='field1'}
{eyou:eq name='$field1.parent_id' value='$field.id'}
{eyou:assign name='$field.currentstyle' value='on' /} <!--標(biāo)簽value='on'里面的on是高亮輸出樣式-->
{/eyou:eq}
{/eyou:type}
{/eyou:eq}
<!--有三級(jí)時(shí)判斷二級(jí)欄目高亮結(jié)束-->
<li> <a href="{$field.typeurl}" class="{$field.currentstyle}"> <span class="iconfont icon-{$field.tubiao}" style="font-size:50px;"></span><br>
<span style="font-size:15px;">{$field.typename}</span> </a> </li>
{/eyou:channel}
<!--獲取二級(jí)欄目結(jié)束-->
</ul>
</div><div class="titles">
<ul>
{eyou:eq name='$eyou.field.grade' value='1'}
<!--沒(méi)有三級(jí)欄目輸出開(kāi)始-->
{eyou:channel type="son" currentstyle="on" id='field2'}
<li ><a href="{$field2.typeurl}" class="one_a transition {$field2.currentstyle}">{$field2.typename}</a></li>
{/eyou:channel}
<!--沒(méi)有三級(jí)欄目輸出結(jié)束-->
{eyou:else /}
{eyou:eq name='$eyou.field.grade' value='2'}
<!--有三級(jí)欄目輸出開(kāi)始-->
{eyou:channel type="sonself" currentstyle="on" id='field2'}
<li ><a href="{$field2.typeurl}" class="one_a transition {$field2.currentstyle}">{$field2.typename}</a></li>
{/eyou:channel}
<!--有三級(jí)欄目輸出結(jié)束-->
{/eyou:eq}
{/eyou:eq}
</ul>
</div>