We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7391
    • 49 Posts
    I’m a creating a blog and on the home page i want to include some meta info about the post. Info such as "Created by", "posted on", "tags".. etc.

    I also want to include a "Posted in" section where I want it to display the name of the container(category) that the blog post is in.

    I am able to do this very easily with getResourceField. However, this only works if i paste this code on the actual article. I want this snippet to return the parent name of a blog article even when I call it another page (ex. blog home, or home page). Any help would be usefull.

    <a href="[[~[[*parent]]]]">[[getResourceField? &id=`[[*parent]]`]] </a>


    Add URL:
    www.josebrowne.com


    Modx rocks!!!!
      • 3749
      • 24,544 Posts
      It’s not clear how you are selecting, retrieving, and displaying the blog posts, or if there’s more than one on the page. It’s tough to answer without more details.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 7391
        • 49 Posts
        I’m temporarily making my site live so that you can more easily see what i’m trying to accomplish. I’ve followed the "Creating a blog" tutorial and made lots of mods to fit my design.

        Check it out:
        www.josebrowne.com

          • 3749
          • 24,544 Posts
          I’m assuming that you’re using getResources to get the posts. In that case, you want to put the tags for the fields you want in the getResource Tpl chunk, using tags like this:

          [[+pagetitle]]


          not like this:

          [[*pagetitle]]


          If there’s something that getResources won’t get, (e.g., the parent pagetitle), you can create a custom snippet to retrieve it -- something like this:

          [[!ParentPagetitle? $pid=`[[+parent]]` ]]



          <?php
          /*ParentPagetitle snippet */
          
          $parent = $modx->getObject('modResource', $pid) ;
          if ($parent) {
              return $parent->get('pagetitle');
          }
          


          You might also be able to use getResourceField in the Tpl chunk instead of the custom snippet if GRF will get the parent pagetitle rather than the ID.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 7391
            • 49 Posts
            Your a Genius!.. love it when I get something to work the way I want it to...

            I just changed the * in my original call to + (because I want the fields of the target resource, not the current resource) and PRESTO!

            Call is now:
            <a href="[[~[[+parent]]]]">[[getResourceField? &id=`[[+parent]]`]] </a>


            MODx 4 Life!
              • 3749
              • 24,544 Posts
              I’m glad it worked for you. Thanks for reporting back. smiley
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 7391
                • 49 Posts
                Oh don’t mention; thank you for the help.. it’s my duty to give back the the Modx Comm.. Hopefully this will help someone else.