qq_35052591
qq_35052591
2017-11-17 03:30

前端大神有没,要求栏目分级到7级,目前是4级

20
  • 前端
 [#assign showCount =5 /]
[#if node.name!='首页']
    [#assign showCount =0 /]
[/#if]
[#assign level1id =0 /]
[#assign level2id =0 /]
[#assign level3id =0 /]
[#assign level4id =0 /]
[#assign currentNodeId =node.id!0/]
[#if node??]
    [#if (node.hierarchy?size) > 1]
        [#assign level1id =node.hierarchy[1].id /]
    [/#if]
    [#if (node.hierarchy?size) > 2]
        [#assign level2id =node.hierarchy[2].id /]
    [/#if]
    [#if (node.hierarchy?size) > 3]
        [#assign level3id =node.hierarchy[3].id /]
    [/#if]
                [#if (node.hierarchy?size) > 4]
        [#assign level4id =node.hierarchy[4].id /]
    [/#if]

[/#if]
<div class="left">
    <div class="left_title">文化动态</div>
    <div class="left_menu">
        [@NodeList;list]
         [#list list as nodeItem]
        <dl>
            <dt>
                 <a class="l1_slide [#if (level1id==nodeItem.id)||(nodeItem_index >= showCount)]open[/#if]">&nbsp;</a>  
                 <a href="${nodeItem.getUrl()!}" class="[#if currentNodeId==nodeItem.id]on1[/#if]" title="${nodeItem.name!}">[#if nodeItem.name?length gt 7]${nodeItem.name?substring(0,7)}...[#else]${nodeItem.name}[/#if]<font class="numFont">(${nodeItem.infoAllCount!})</font></a>
            </dt>
            [@NodeList parentId=nodeItem.id;children] 
            [#list children as childNode]
            [@infoCount isIncludeChildren=true nodeId=childNode.id;level2Count]
            <dd style="[#if level1id!=nodeItem.id &&(nodeItem_index>=showCount)]display:none;[/#if]">
                   <a class="l2_slide [#if (childNode.children?size)==0 || (level2id!=childNode.id)]open[/#if]">&nbsp;</a>  
                   <a href="${childNode.url}" class="[#if currentNodeId==childNode.id]on1[/#if]" title="${childNode.name!}">[#if childNode.name?length gt 7]${childNode.name?substring(0,7)}...[#else]${childNode.name}[/#if]<font class="numFont">(${level2Count})</font></a>
                   <ul style="[#if !((childNode.children?size)==0 || (level2id!=childNode.id))]display:block;[#else]display:none;[/#if]">
                        [#list childNode.children as grantChild]
                                 [@infoCount nodeId=grantChild.id isIncludeChildren=true;level3Count]
                                     [#if level3Count>0]
                                            <li>
                                    <a href="${grantChild.url}" title="${grantChild.name!}" class="[#if currentNodeId==grantChild.id]on1[/#if] [#if node?exists][#if node.hierarchy[3]?exists][#if node.hierarchy[3].id==grantChild.id]on[/#if][/#if][/#if]">${grantChild.name}<font class="numFont">(${grantChild.infoAllCount!})</font></a>
                                        [#if grantChild.children?size>0]
                                            <ul class="four_list" style="[#if currentNodeId==grantChild.id || node.parent.id==grantChild.id]display:block;[#else]display:none;[/#if]">
                                                [#list grantChild.children as child]
                                                 <li  class="[#if currentNodeId==child.id]on1[/#if]" onclick="location.href='${child.url!}'" style="cursor:pointer" ><i onclick="location.href='${child.url!}'">.</i>${child.name!}(${child.infoAllCount!})</li>
                                                [/#list]
                                            </ul>
                                              [/#if]
                                  </li>
                            [/#if]
                                   [/@infoCount]
                           [/#list]
                   </ul>
            </dd>
            [/@infoCount]
            [/#list]
          [/@NodeList]
        </dl>
            [/#list] 
            [/@NodeList]
    </div>
</div>
<script>
$(".left_menu").find(".l1_slide").each(function(i,e){
    var _this = $(this)
    _this.on('click',function(){
        $(".left_menu").find("dd").hide();
        $(".left_menu").find(".l1_slide").addClass("open");

        _this.parent("dt").siblings("dd").slideToggle("fast");
        _this.toggleClass("open");
    })
});
$(".left_menu").find(".l2_slide").each(function(i,e){
    var _this = $(this)
    _this.on('click',function(){

        _this.parents("dl").find(".l1_slide").click();

        _this.parents("dl").find("ul").hide();
        _this.parents("dl").find(".l2_slide").addClass("open")


        _this.siblings("ul").slideToggle("fast");
        _this.toggleClass("open");
    })
});
</script>
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答