在使用j9九游时,遇到栏目页或者内容页二级栏目导航和三级栏目导航分开调用时,标签如何调用呢?先在公用函数文件里加一截代码,。
公用函数文件extend/function.php打开后在底部添加下面代码
/**
* 获取顶级栏目下是否3级,并输出指定的字符
* 模板使用方法:{$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 '';
}
}
然后下面时模板使用代码,注意样式文件自己修改
{eyou:channel type="first" currentstyle="on" id='field'}
{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' /}
{/eyou:eq}
{/eyou:type}
{/eyou:eq}
{/eyou:channel}
{eyou:eq name='$eyou.field.grade' value='1'}
{eyou:channel type="son" currentstyle="on" id='field2'}
{/eyou:channel}
{eyou:else /}
{eyou:eq name='$eyou.field.grade' value='2'}
{eyou:channel type="sonself" currentstyle="on" id='field2'}
{/eyou:channel}
{/eyou:eq}
{/eyou:eq}