Basically I want to have each child menu only display on the parent menu ID. But so far, all I can get is all of the child li
's connecting to any parent menu I set up.
Here is a diagram to explain how the menu is displaying right now:
Home
About > Employment & Mobile (I only want employment to display)
Services > Employment & Mobile (I only want mobile to display)
Contact
So the queries output the following variables from the database
- pg_LinkName
- pg_MenuTitle
- pg_ParentMenu (the name of the parent menu),
- pg_MenuType (a yes/no to say if it is a parent/sub menu),
- pg_SubMenu (a yes/no to specify whether the menu is a parent menu or not)
I want to know if there's a way to connect the child to the parent dynamically. eg. If I choose to attach a page to a parent, it only shows on that parent in the drop down.
Here are my queries:
<cfquery name="qry_GetMenu" datasource="#request.dsn#">
SELECT *
FROM tbl_pages
WHERE pg_MenuType = TRUE AND pg_Display = TRUE AND pg_AutoMenu = TRUE AND pg_Horiz_VertMenu = TRUE
ORDER BY pg_sort
</cfquery>
<cfquery name="qry_GetSubMenus" datasource="#request.dsn#">
SELECT *
FROM tbl_pages
WHERE pg_MenuType = FALSE
ORDER BY pg_sort
</cfquery>
<cfquery name="qry_SubMenu" datasource="#request.dsn#">
SELECT *
FROM tbl_pages
WHERE pg_SubMenu = TRUE
ORDER BY pg_sort
</cfquery>
And this is what I have for the menu:
<ul class="menu">
<cfoutput query="qry_GetMenu">
<li <cfif cgi.path_info contains "#pg_LinkName#"> class="current-menu-parent"</cfif>>
<a href="#systemurl#/index.cfm/#pg_LinkName#/">#pg_MenuTitle#</a>
<cfif pg_SubMenu gt 0>
<ul class="sub-menu">
<cfloop query="qry_GetSubMenus">
<li><a href="#systemurl#/index.cfm/#pg_ParentMenu#/#pg_LinkName#/">#pg_MenuTitle#</a></li>
</cfloop>
</ul>
</cfif>
</li>
</cfoutput>
</ul>