下载如下文件,将jquery.ztree.all-3.4.min.js放入项目中,然后打开某一个频道的频道页或列表页或内容页,将channel_classtree.htm的内容粘贴进去,同时别忘了引入js和css。
当然,也支持在其他页,只要不{$ChannelId}改成固定值即可。
<ul id="channelClassTree" class="ztree"></ul>
<script type="text/javascript">
<!--
//支持四层分类,更多分类请自行嵌套
var classtree$setting = {};
var classtree$zNodes =[
<jcms:classtree channelid="{$ChannelId}" classid="0">
<#foreach collection="${tree.subchild}" var="class0" index="a">
<#if test="${notequals(a, 1)}">,<#/if>
{ "name":"${class0.name}", "target":"_self", "url":"${class0.link}"
<#if test="${notequals(class0.subchild.count, 0)}">
,children: [
<#foreach collection="${class0.subchild}" var="class1" index="b">
<#if test="${notequals(b, 1)}">,<#/if>
{ "name":"${class1.name}", "target":"_self", "url":"${class1.link}"
<#if test="${notequals(class1.subchild.count, 0)}">
,children: [
<#foreach collection="${class1.subchild}" var="class2" index="c">
<#if test="${notequals(c, 1)}">,<#/if>
{ "name":"${class2.name}", "target":"_self", "url":"${class2.link}"
<#if test="${notequals(class2.subchild.count, 0)}">
,children: [
<#foreach collection="${class2.subchild}" var="class3" index="d">
<#if test="${notequals(d, 1)}">,<#/if>
{ "name":"${class3.name}", "target":"_self", "url":"${class3.link}"}
<#/foreach>
]
<#/if>
}
<#/foreach>
]
<#/if>
}
<#/foreach>
]
<#/if>
}
<#/foreach>
</jcms:classtree>
];
$(document).ready(function(){
$.fn.zTree.init($("#channelClassTree"), classtree$setting, classtree$zNodes);
});
//-->
</script>