cancel
Showing results for 
Search instead for 
Did you mean: 

Section Menu

foosetv
Champ in-the-making
Champ in-the-making
I'm looking for some help with the syntax in making a menu for a WCMQS site. What I'm looking to do is have a menu that lists only the first level of sections within a particular section. For instance I want the menu to list all the sections underneath the "news" section and to display them when I'm in any page in the news section including any of the news' nested sections. I've had some limited success with this:


<#list section.sections as section>
     <#if ! section.excludeFromNav>
          <li><a href="${url.context}${section.path}"><#if section.title?? && section.title?length gt 0>${section.title}<#else>${section.name}</#if></a>   
          </li>
     </#if>
</#list>
While this works when on a root level for the section, it does not work when you are in a nested section because it us looking for another set of nested sections. Is there a way in the Freemarker list tag to reference the parent section or reference a specific section by name or level (in a nested sence)? The only two references I know of are webSite.sections for the root folders and section.sections for the current section.
1 REPLY 1

bremmington
Champ on-the-rise
Champ on-the-rise
In general terms I suggest getting the id of the root section (rootId = webSite.rootSection.id) and then iterating up the section tree (using section.containingSection) until you reach the section immediately before (section.id == rootId). At that point you have found the top level section relevant to the requested URL, and you can then use topLevelSection.sections to find the ones you want to display in your nav. This logic would probably be best done in the Javascript controller of the component rather than the Freemarker view, but either would work. Hope that helps.