We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18367
    • 834 Posts
    Hi I'm trying to output the folder parent name of a document as a piece of meta data..

    IE
    <meta itemprop="articleSection" content="[[!getResourceField? &id=`[[*parent]] &field=`pagetitle`]]">


    With no luck.

    I tried with just [[*parent]] but that just returns the id number.

    Any ideas?

    Thanks

    This question has been answered by lkfranklin. See the first response.

    [ed. note: markg last edited this post 8 years, 8 months ago.]
      Content Creator and Copywriter
    • discuss.answer
      • 17301
      • 932 Posts
      Bobray has a great post on this here:

      https://bobsguides.com/blog.html/2014/01/17/getting-a-parents-pagetitle/

      Instead of pagetitle you could use it to get additional fields instead such as alias.

      $output = $parentObj->get('alias');



      To get all fields that you can then use as a placeholder simply call into an array

      <?php 
      $output = '';
      $tpl = $modx->getOption('tpl', $scriptProperties, 'ParentInfoTpl', true);
      $parent = $modx->getObject('modResource', array('id' => $modx->resource->get('parent')));
      if ($parent) {
          $fields = $parent->toArray();
          $output = $modx->getChunk($tpl, $fields);
      }
      return $output;


      And then call your snippet and specify a tpl chunk

      [[!ParentInfo? &tpl=`ParentInfoTpl`]]
      [ed. note: lkfranklin last edited this post 8 years, 8 months ago.]
        ■ email: [email protected] | ■ website: https://alienbuild.uk

        The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
        • 18367
        • 834 Posts
        LK,

        I just used Bob's snippet exactly as is and it worked perfectly.

          Content Creator and Copywriter