We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4775
    • 47 Posts
    What can I use to get the page title of the parent document to display?

    I can use this to get the ID:
    [+parent+]

    But what can I use to get the page title of the parent?

    I’ll be using it like this:

    <a href="[~[+parent+]~]">[+pagetitleofparent+]</a>

    [+pagetitleofparent+] is obviously incorrect. I need to do this without needing to create a template variable (TV).

    Is it possible to combine document variables? [+pagetitle+] + [+parent+] = [+pagetitleofparent+]. (If not, that sounds like a cool feature request to me... a lot of possibilities there)

    Thanks in advance!
      • 33372
      • 1,611 Posts
      The following snippet will return the page title of the parent document:
      <?php
      $docInfo=$modx->getDocument($modx->documentObject['parent'],'pagetitle');
      return $docInfo['pagetitle'];
      ?>
        "Things are not what they appear to be; nor are they otherwise." - Buddha

        "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

        Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
        • 4775
        • 47 Posts
        Thanks for the replies I was able to do it with just the GetField snippet:

        <a href="[~[+parent+]~]">[[GetField? &docid=`[+parent+]` field=`pagetitle`]]</a>