Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
537 views
in Technique[技术] by (71.8m points)

coldfusion - trying to create a horizontal menu with struct data i have

I have the following type of structure https://prnt.sc/wkerdv

in the above only the first one has childrens but the possibility is childrens can have childrens and so on, but i prefer to display only 3 levels deep as horizontal menu

i am struk the loop where i had to add the loop properly to create the menu bar, i am trying to create menu like this

https://prnt.sc/wket5s

so here is what i am trying

<cfoutput>
    <ul>
<cfloop from="1" to="#arrayLen(data.item)#" index="i">
  <cfset x = data.item[i]>
  <cfloop collection="#x#" item="key">
      <cfif Structkeyexists(key,'Item')>
          <cfloop from="1" to="#arrayLen(data.item)#" index="i">
          <cfset x = data.item[i]>
      <cfelse>


      </cfif>    
          <cfdump var="#key#">
          <!--- <cfloop from="1" to="#arrayLen(key.item)#" index="d">
               <cfset n = key.item[d]>
                    <!--- <li>#d#:#n[d]#</li> --->
                    <cfdump var="#n#">
          </cfloop>
     
            <li>#key#:#x[key]#</li>--->  
       
  </cfloop>
</cfloop>
</ul>
</cfoutput>

the html code behind the above second screen is like this

<ul class="menu-list">
        <cfloop from="1" to="#ArrayLen(data.menu.item)#" index="toplevel">
            <li><a href="01_Home Page.html">#toplevel#</a>
        </cfloop>
        <li class="active"><a href="01_Home Page.html">HOME</a>
            <ul class="menu-dropdown">
                <li><a href="01_Home Page.html">Home One</a></li>
                <li><a href="02_Home Page.html">Home Two</a></li>
                <li><a href="03_Home Page.html">Home Three</a>
                    <ul class="thirdlevel-menu">
                        <li><a href="">Thirdlevel</a></li>
                        <li><a href="">Thirdlevel</a></li>
                        <li><a href="">Thirdlevel</a></li>
                    </ul>
                </li>
            </ul>
        </li>
        <li><a href="">ABOUT</a></li>
        <li><a href="">SHOP</a>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...