We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20648
    • 26 Posts
    What is the easiest way to show a dynamic main section header?

    I have a tree structure

    section 1
    section sub 1
    section sub 1
    section sub sub 1
    section sub sub 1

    section 2
    section sub 2
    section sub 2
    section sub sub 2
    section sub sub 2


    What I would like is to always show the title of the "root section". If I travel down to section sub sub 1 page, I want to show the title of section 1 on the same page.
    If I use the [*menutitle*] I always get the title of the page I’m on. Is there a way to get only the "top section" title instead?
      • 11975
      • 2,542 Posts
      Hi,

      you can use getField snippet and ultimateParent.


      [!getField? &docid=`[[UltimateParent]]` &field=`pagetitle` !] should do the trick

      :-)

      EDIT: you could add a conditionnal statement with PHx to display the section header if needed

      [+phx:if=`parent`:ne=`0`:then=`[!getField? &docid=`[[UltimateParent]]` &field=`pagetitle` !]`+]
        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
        • 20648
        • 26 Posts
        Yes, that worked. Thanks for quick reply.
          • 2214
          • 33 Posts
          I am having a similar problem, although the pagetitle (section header) I need to print is really at the second level beneath UltimateParent.



          If I use the UltimateParent snippet, I get Feverish Home as the imprinted text. Is there a way to drill down parentlevels instead of going up the document tree?
            • 1511
            • 144 Posts
            Check the &top parameter of the UltimateParent.
            It tells the snippet where to stop going upwards in the tree.

            In your case, set &top=`2` and you’ll get the desired result.