Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5937715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:34:54+00:00 2026-05-22T15:34:54+00:00

Wow. I have been asked to add a 3rd level to a tree menu

  • 0

Wow. I have been asked to add a 3rd level to a tree menu for a company. Below is what I found had created about 6 months ago. And while it works, there is no way I am going to add another cfloop hack to it. All my feelings tell me this just bad code and to redo.

I cannot change the databased nor have the results returned in anything else other than a query. now you know the way it has to be, what are my options here???

Each record in the DB has NO relationship, the code below just looks at the name of the widget and works out if it is a parent or not based on the :

examples of widgetName

1= Compliance:

2= Compliance: Document Library:

3= Compliance: Document Library: All Firms

so above says that widget 2 should be 2 levels down. look at the code you will see in a very bad way what has been done….

<cfoutput>

<ul id="root" class="menu">     

     <cfloop array="#rc.widgets.getPageRecords()#" index="local.widgets">


         <cfif listLen(local.widgets.getwidgetName(),":") eq 1>
          <li>

            <a href='javascript:void(0);' childid = '#local.widgets.getwidgetID()#' class='cat_close category'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
            <a href='javascript:void(0);'>#local.widgets.getwidgetName()# - #listLen(local.widgets.getwidgetName(),":")#</li></a>
            <cfset wordToFind = local.widgets.getwidgetName()>
            <ul id='#local.widgets.getwidgetID()#'>
                 <cfloop array="#rc.widgets.getPageRecords()#" index="local.widgets">
                     <cfif listLen(local.widgets.getwidgetName(),":") eq 2 AND  #find(wordToFind,local.widgets.getwidgetName())#>
                        <li>
                            <a href='javascript:void(0);' childid = '#local.widgets.getwidgetID()#' class='cat_close category'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
                            <a href='javascript:void(0);'>#local.widgets.getwidgetName()# - #listLen(local.widgets.getwidgetName(),":")#</li></a>
                        </li>
                     </cfif>
                 </cfloop>
            </ul>
         </cfif>


     </cfloop>



</ul>
</cfoutput>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:34:55+00:00Added an answer on May 22, 2026 at 3:34 pm

    I would use a recursive function to do this, that would give you unlimited future compatibility. I’m not sure what the data you are working with looks like, but it seems as though it should be possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There have been many debates about this topic already here, but none of them
I've been evaluating various smart pointer implementations (wow, there are a LOT out there)
I've been asked by my boss to make a semi-functional mockup of a webapp
I have been having problems with creating a download list of files for a
I have been stuck on this all weekend and failed miserably! Please help me
This question is long winded because I have been updating the question over a
I am having a lot of fun with Linq2Sql. Expression Trees have been great,
Here we go down the subjective alley .. Lately, I have been adding a
Wow, I just got back a huge project in C# from outsourced developers and
Wow, it's hard to find a simple explanation to this topic. A simple many-to-many

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.