Is there a way to display section titles on sublevel pages without creating a separate template?

Is there a way to use the title value of a parent page in an if condition statement?

I'm displaying the parent page title as a section name on sublevel pages, but don't want the section name to show on the top-level section page.

This is what I've tried:

<div id="section_name">
  <w:parent><w:if condition="title != '/'"><w:title /></w:if></w:parent>
</div>

 

Have more questions? Submit a request

4 Comments

  • 0
    Avatar
    Cindy

    correction: the condition above should read "url != '/'"

  • 0
    Avatar
    Cindy

    I have another similar question as above in regards to using the menu, and parent and child pages.  I'm attaching a screen capture of a top level page.

    • Is it possible to add a condition where the parent page title will only show (above the page title on the shaking hands image)  if the current page is not the first child of the home page?
    • The list of pages in the content portion uses the Webvanta script to iterate through the child pages of that page.  However, it won't list the external links from the menu - had to add those manually.  Is there a way to iterate through the menu instead, of only the current page, so it lists the external links?



    screen1.png
  • 0
    Avatar
    Andrew DesChenes

    Cindy,

     

    Regarding your first question and code snippet: the title field is not available to the condition attribute.  We also do not support a "NOT EQUAL" operator such as "!=".  Use this instead:  

    <w:parent><w:unless_url matches='^/$'><w:title /></w:unless_url></w:parent>  

    This uses a regular expression in the matches attribute to look for the home page.

  • 0
    Avatar
    Andrew DesChenes

    Cindy,

    Regarding the second question about displaying submenu items including external links:

    Using the <w:children:each> loop you have will only loop through pages, not external links.  You want to loop through the menu itself.  This is what the main_menu snippet on your site does (in the default theme it's in the header snippet).  Deriving from that code I wrote this should work for you:

    <w:menu>
      <w:each>
        <w:if_url matches="member_center">
          <ul>
            <w:submenu:each>
              <li><a href='<w:url  />'><w:label /></a></li>
            </w:submenu:each>
          </ul>  
        </w:if_url>
      </w:each>    
    </w:menu>

    You can change the page reference in the matches attribute of the if_url tag to whatever top level page you want to use this on.  I've already placed this code on your members_center page.

Please sign in to leave a comment.
Powered by Zendesk