[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Displaying parent, child, grandchild pages in a navigation menu; only one child will display

Posted on 2012-03-31
4
Medium Priority
?
584 Views
Last Modified: 2012-06-27
MS SQL Server 2005
CF 9.0.1
Hi. I've been working on this for a while, and need a hint. I am trying to display parent, child, grandchild pages in a navigation menu. Here is my query:
<!--- get table columns for parent, child, grandchild records--->
<cfquery name="getPages" datasource="#APPLICATION.dataSource#">
SELECT
       p.PageID     AS PageIDLevel1
      ,p.PageTitle  AS PageTitleLevel1
      ,p.SortOrder  AS SortOrderLevel1
      ,p.ParentID   AS ParentIDLevel1
      ,p.safeURL AS safeURLLevel1
      ,c.PageID     AS PageIDLevel2
      ,c.PageTitle  AS PageTitleLevel2
      ,c.SortOrder  AS SortOrderLevel2
      ,c.parentID   AS ParentIDLevel2
      ,c.safeURL AS safeURLLevel2
      ,gc.PageID    AS PageIDLevel3
      ,gc.PageTitle AS PageTitleLevel3
      ,gc.SortOrder AS SortOrderLevel3
      ,gc.parentID  AS ParentIDLevel3
      ,gc.safeURL AS safeURLLevel3

FROM #REQUEST.contentTable# p
                  LEFT JOIN #REQUEST.contentTable#  c ON c.parentID = p.pageID
                  LEFT JOIN #REQUEST.contentTable#  gc ON gc.parentID = c.PageID
WHERE ISNULL(p.parentID, 0) = 0
ORDER BY p.SortOrder asc, c.SortOrder asc, gc.SortOrder asc
</cfquery>

Open in new window


And here is the output:
<!--- menu --->
<ul class="menu">
      
<cfoutput query="getPages" group="PageTitleLevel1">

<!--- begin level 1, list of parent pages; each parent is enclosed in a list item (li) tag --->
<cfoutput group="SortOrderLevel1">
  <li><a href="/pages/#getPages.safeURLLevel1#.cfm">#getPages.PageTitleLevel1#</a>

<!--- begin level 2, list of child pages; each child is enclosed in a list item (li) tag --->
		<cfoutput group="SortOrderLevel2">
        <cfif len(pageTitleLevel2)><!--- does a level 2, child record exist?--->
        <ul>  
        <li>
        <a href="/pages/#getPages.safeURLLevel2#.cfm">#getPages.PageTitleLevel2#</a> 

<!--- begin level 3, list of grandchild pages; each grandchild is enclosed in a list item (li) tag --->
				
				  <cfoutput group="SortOrderLevel3">
                  <cfif len(PageTitleLevel3)>  <!--- does a level 3, grandchild record exist?--->
                  <ul>  
                  <li>
                  <a href="/pages/#getPages.safeURLLevel3#.cfm">#getPages.PageTitleLevel3#</a>
                  </li>
                  </ul>
                  </cfif>
                  </cfoutput><!--- close level 3 li, ul, cfif, cfoutput ---> 
 
        </li>
        </ul>
        </cfif>
        </cfoutput><!--- close level 2 li, ul, cfif, cfoutput --->
   
  
</li></cfoutput>
<!--- close level 1 li, cfoutput --->

</cfoutput><!--- close query getPages cfoutput --->
   

</ul><!--- close menu ul --->
   
        <!--- /menu --->

Open in new window


The problem is, the output displays all of the parents; but, only the first child is displayed. There should be five child pages under the About parent page. You can see the problem here:

http://test.ebwebwork.com/

I am pretty sure that I have gotten the output correct, carefully placing all ul, li, cfif, and cfoutput tags. So I am thinking there is something going wrong in my query.

What do you think? Thanks for taking a look at this.

Eric
0
Comment
Question by:Eric Bourland
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 39

Accepted Solution

by:
gdemaria earned 2000 total points
ID: 37792022
perhaps this?


<ul class="menu">
<cfoutput query="getPages" group="PageTitleLevel1">
  <!--- begin level 1, list of parent pages; each parent is enclosed in a list item (li) tag --->
  <li><a href="/pages/#getPages.safeURLLevel1#.cfm">#getPages.PageTitleLevel1#</a>

        <!--- begin level 2, list of child pages; each child is enclosed in a list item (li) tag --->
            <cfoutput group="pageTitleLevel2">
        <cfif len(pageTitleLevel2)><!--- does a level 2, child record exist?--->
        <ul>  
        <li>
        <a href="/pages/#getPages.safeURLLevel2#.cfm">#getPages.PageTitleLevel2#</a>

                  <!--- begin level 3, list of grandchild pages; each grandchild is enclosed in a list item (li) tag --->
                          <cfoutput>
                  <cfif len(PageTitleLevel3)>  <!--- does a level 3, grandchild record exist?--->
                  <ul>  
                  <li>
                  <a href="/pages/#getPages.safeURLLevel3#.cfm">#getPages.PageTitleLevel3#</a>
                  </li>
                  </ul>
                  </cfif>
                  </cfoutput><!--- close level 3 li, ul, cfif, cfoutput --->
 
        </li>
        </ul>
        </cfif>
        </cfoutput><!--- close level 2 li, ul, cfif, cfoutput --->
</li></cfoutput>
<!--- close level 1 li, cfoutput --->
</cfoutput><!--- close query getPages cfoutput --->
</ul><!--- close menu ul --->
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 37792042
gdemaria, good to hear from you.

I see how you simplified the code. There was an extra </cfoutput> at the end that I omitted. I used your optimized code, but I am still getting only one child page in the output.

I am taking another look at the query. Eric

<ul class="menu">
<cfoutput query="getPages" group="PageTitleLevel1">
  <!--- begin level 1, list of parent pages; each parent is enclosed in a list item (li) tag --->
  <li><a href="/pages/#getPages.safeURLLevel1#.cfm">#getPages.PageTitleLevel1#</a>

        <!--- begin level 2, list of child pages; each child is enclosed in a list item (li) tag --->
            <cfoutput group="pageTitleLevel2">
        <cfif len(pageTitleLevel2)><!--- does a level 2, child record exist?--->
        <ul>  
        <li>
        <a href="/pages/#getPages.safeURLLevel2#.cfm">#getPages.PageTitleLevel2#</a> 

<!--- begin level 3, list of grandchild pages; each grandchild is enclosed in a list item (li) tag --->
                  <cfoutput>
                  <cfif len(PageTitleLevel3)>  <!--- does a level 3, grandchild record exist?--->
                  <ul>  
                  <li>
                  <a href="/pages/#getPages.safeURLLevel3#.cfm">#getPages.PageTitleLevel3#</a>
                  </li>
                  </ul>
                  </cfif>
                  </cfoutput><!--- close level 3 li, ul, cfif, cfoutput ---> 
 
        </li>
        </ul>
        </cfif>
        </cfoutput><!--- close level 2 li, ul, cfif, cfoutput --->
        
</li><!--- close level 1 li --->
</cfoutput><!--- close getPages --->
</ul><!--- close menu ul --->

Open in new window

0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 37792184
I got it:  =)

    
<ul class="menu">
<cfoutput query="getPages" group="PageTitleLevel1">
  <!--- begin level 1, list of parent pages; each parent is enclosed in a list item (li) tag --->
  <li><a href="/pages/#getPages.safeURLLevel1#.cfm">#getPages.PageTitleLevel1#</a>

        <!--- begin level 2, list of child pages; each child is enclosed in a list item (li) tag --->
            
        <cfif len(pageTitleLevel2)><!--- does a level 2, child record exist?--->
        <ul>
        <cfoutput group="pageTitleLevel2">  
        <li>
        <a href="/pages/#getPages.safeURLLevel2#.cfm">#getPages.PageTitleLevel2#</a> 

<!--- begin level 3, list of grandchild pages; each grandchild is enclosed in a list item (li) tag --->
                  
                  <cfif len(PageTitleLevel3)>  <!--- does a level 3, grandchild record exist?--->
                  <ul>
                  <cfoutput>  
                  <li>
                  <a href="/pages/#getPages.safeURLLevel3#.cfm">#getPages.PageTitleLevel3#</a>
                  </li>
                  </cfoutput>
                  </ul>
                  </cfif>
                  <!--- close level 3 li, ul, cfif, cfoutput ---> 
 
        </li>
        </cfoutput>
        </ul>
        </cfif>
        <!--- close level 2 li, ul, cfif, cfoutput --->
        
</li><!--- close level 1 li --->
</cfoutput><!--- close getPages --->
</ul><!--- close menu ul --->  

Open in new window

0
 
LVL 3

Author Closing Comment

by:Eric Bourland
ID: 37792187
Thanks as always to gdemaria. Happy Saturday evening. Hope you're well.

Eric
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question