We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25803 ☆ A M B ☆
    • 721 Posts
    I have a site I’m working on where the title of a parent document will be the main title on all the sub document pages. For example:

    About Us
    - Our History
    - Locations
    - Staff

    So the Staff page would be something like this:

    <h1>About Us</h1>
    <h2>Staff</h2>
    <p>whatever</p>


    Whereas the parent of About Us page would be:

    <h1>About Us</h1>
    <p>whatever</p>
    

    I would prefer to use the same Template for both but I can’t figure out how to make the <h2> conditional.

    To grab the parent [*longtitle*] I’m using Get Field:

    <h1>[!GetField? &parent=`1`&field=`longtitle`!]</h1>


    And I can use menutitle or longtitle on the child documents in the <h2> but need the <h2> to not be rendered when on the parent document.

    I’ve tried PHx but to no avail:

    [+phx:if=`[*menutitle*]`:isnot=`[!GetField? &parent=`1`&field=`longtitle`!]`:then=`<h4>[*menutitle*]</h4>`+] 


    Tried it with an else as well that was empty. No luck.
      • 19369
      • 1,098 Posts
      What about this?
      [+phx:if=`[[UltimateParent? &topLevel=`2`]]`:is=`[[UltimateParent? &topLevel=`1`]]`:then=``:else=`<h2>[*longtitle*]</h2>`+]


      With this code the <h2> tag appears only when you are in a submenu
        • 25803 ☆ A M B ☆
        • 721 Posts
        Thanks microcipcip, works wonderfully.
          • 19369
          • 1,098 Posts
          I think that the code above works only when the parent Resource is located in the top level menu. It would be cool to have a snippet that return the level of a resource. Something like this:
          [[MenuLevel]]

          So it would work for a parent which is in a deeper level.