We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 53647
    • 2 Posts
    I'm use Collections add-on in two site pages. For whis two pages as parents I have few internal pages as childs.
    It's not a problem to get link for parent page inside child page template by [[~[[*parent]]]]. But I can't find how I can get parent page title inside child page template.
    Please help!
      • 42562
      • 1,145 Posts
      Here you go:
      https://forums.modx.com/thread/11074/display-the-parent-s-pagetitle?page=2#dis-post-454048

      Create a snippet:
      myVeryOwnFieldGrabber
      $field = "pagetitle"; //default value
      if($modx->resource && !$id){
        $id = $modx->resource->get('parent'); //default value
      }
      
      if($grabResource = $modx->getObject('modResource', $id)){
        return $grabResource->get($field);
      }


      Use in Template like this

      [[!myVeryOwnFieldGrabber]]
      or
      [[!myVeryOwnFieldGrabber? &id=`[[*parent]]` &field=`pagetitle`]]
      [ed. note: donshakespeare last edited this post 9 years, 1 month ago.]
        TinymceWrapper: Complete back/frontend content solution.
        Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
        5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
        • 15001
        • 697 Posts
        You don't mention if you're using MODx Evolution or MODx Revolution.

        For MODx Evolution, you can use the GetField snippet:
        https://modx.com/extras/package/getfield

        If I remember correctly, your snippet call should be something like:
        [!GetField? &docid=`[*parent*]` &field=`pagetitle` !]
        or, if from within a chunk used by another snippet:
        [!GetField? &docid=`[+parent+]` &field=`pagetitle` !]
          • 42562
          • 1,145 Posts
          I don't know if the Extra called Collections works in Evo
            TinymceWrapper: Complete back/frontend content solution.
            Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
            5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
            • 45766
            • 78 Posts
            For Revolution use the extra FastField

            [[#[[+parent]].pagetitle]]