We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22327
    • 0 Posts
    Hello

    I have minor issue thats taking me for a ride.
    I use getResources to generate the slides of a slideshow.
    The images are sub resources, but i want to pull the Introtext from the Parent Resource.

    Somehow I can only get the ID of the parent ressource ( it returns the number (x), but i want the introtext from that resource (x)
    The template chunk i am using looks like this:

    <div class="slide">
      <img src="[[phpThumbOf? &input=`assets/images/[[+document-image]]` &options=`&w=640`]]"alt="[[+pagetitle]]"/>
      <p class="description">[[+parent[[+introtext]]]]</p>
      <a href="[[++filemanager_path]][[+document-image]]">Original Image</a>
    </div>
    


    It´s probably straight forward, but i thought i would post it, because the template chunk might inspire someone

    Keep It Up All You Cool People
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      You can’t use it like that - [[+parent[[+introtext]] - the only thing that’s available in any resource is the [[+parent]] placeholder which holds the ID like you said.

      You can simply use a snippet to fetch the rest of the parent though. Have a look at getResourceField.

        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 3749
        • 24,544 Posts
        You could do it with a custom snippet -- something like this:


        [[!ParentIntrotext? &pid=`[[+parent]]`]]


        <?php
        /* ParentIntrotext snippet */
        $parent = $modx->getObject('modResource', $scriptProperties['pid']);
        if ($parent) {  /* make sure there *is* a parent */
            return $parent->get('introtext');
        }


          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
          • 22327
          • 0 Posts
          Thanks
          One problem - multiple solutions - that´s MODX in a nutshell tongue

          @Mark
          I was just trying not to use getResourceField since it is beta, and i wanted to avoid to many snippet calls within snippet calls. Also i just upgraded to 2.1 and now the download of getResourceField via Package Management doesn´t work anymore. Guess it is one of those Add-Ons that need a rewirte for 2.1

          @Bob
          Tried your code. Created a snippet with the name: ParentIntrotext, but it didn´t work. I think i found 2 minor typos. A missing backtick here:
          [[!ParentIntrotext? $pid=`[[+parent]] ]]`]]


          And the snippet call wasn´t properly closed:
          <?php
          /* ParentIntrotext snippet */
          $parent = $modx->getObject('modResource', $scriptProperties['pid']);
          if ($parent) {  /* make sure there *is* a parent */
              return $parent->get('introtext');
          }
          


          Am i missing anything else ?
          Thanks and no worries, you all inspired me for a plan B.
            • 22327
            • 0 Posts
            Sorry I am new to this forum. I made a typo.

            It should be:
            [[!ParentIntrotext? $pid=`[[+parent]]`]]
            

              • 33968
              • 863 Posts
              Should be:
              [[!ParentIntrotext? &pid=`[[+parent]]`]]
              

              With an ’&’ smiley
                • 3749
                • 24,544 Posts
                Thanks! tongue

                Fixed above.
                  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