navigation - Coldfusion Need Help Parent / Child Dynamic Menu -


basically want have each child menu display on parent menu id. far, can of child li's connecting parent menu set up.

here diagram explain how menu displaying right now:

  • home

    about > employment & mobile (i want employment display)

    services > employment & mobile (i want mobile display)

  • contact

so queries output following variables database

  • pg_linkname
  • pg_menutitle
  • pg_parentmenu (the name of parent menu),
  • pg_menutype (a yes/no if parent/sub menu),
  • pg_submenu (a yes/no specify whether menu parent menu or not)

i want know if there's way connect child parent dynamically. eg. if choose attach page parent, shows on parent in drop down.

here queries:

<cfquery name="qry_getmenu" datasource="#request.dsn#">      select *     tbl_pages      pg_menutype = true , pg_display = true , pg_automenu = true , pg_horiz_vertmenu = true     order pg_sort </cfquery>  <cfquery name="qry_getsubmenus" datasource="#request.dsn#">      select *     tbl_pages      pg_menutype = false      order pg_sort </cfquery>  <cfquery name="qry_submenu" datasource="#request.dsn#">      select *     tbl_pages     pg_submenu = true     order pg_sort </cfquery> 

and have 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> 

if i'm understanding correctly, want display assigned children under corresponding parent, , code displaying child elements under every parent displayed?

with current code, need move 1 of queries in line

<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">         <!---moved inline add additional conditional pg_parentmenu clause--->         <cfquery name="qry_getsubmenus" datasource="#request.dsn#">               select * q pg_menutype = 0 , pg_parentmenu = '#pg_parentmenu#'         </cfquery>             <cfloop query="qry_getsubmenus">                 <li><a href="#systemurl#/index.cfm/#pg_parentmenu#/#pg_linkname#/">#pg_menutitle#</a></li>             </cfloop>         </ul>     </cfif>     </li> </cfoutput> 

this allow query filtered current parent menu opposed parent menus. if huge data set, become pretty inefficient. there lots of options @ point (perform loops , assign object array of structs has keys parent , children, children being array, or re-working database make sub-menus relational, etc.).

hope moving in right direction.


Comments