Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
530 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 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...