We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7527
    • 437 Posts
    I have recently been using the getRelated snippet, one that I really wished was available to me back when I was using Evo! I have set my following call up at the bottom of my pages:

    [[getRelated? &parents=`26` &hideContainers=`1` &fields=`pagetitle:3,introtext:2,tv.tags:5` &returnTVs=`Related`]]


    and the TV 'Related' contains:

    <div class="entry">
    <h4><a href="[[~[[+id]]]]" rel="bookmark" title="Permanent Link to [[+pagetitle]]">[[+pagetitle]]</a></h4>
    <a href="[[~[[+id]]]]"><img class="alignleft" title="[[+tv.Factfile_title]]" src="[[+tv.Fact1:phpthumbof=`w=100&h=100&zc=1`]]" alt="" /></a>
    </div>


    It works well in the sense that it returns a linked pagetitle but it does not return the image specified as Fact1.

    Eventually I will have a row of 5 related examples (picture and text) so if anyone can also explain how to make them appear in a row (as opposed to a vertical stack) I would appreciate it

    Thanks for all the help so far

    Regards,

    DS
      www.PawsForWildlife.co.uk
      www.Borntobrick.co.uk
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      Hi DS,

      I think you've misunderstood the returnTVs property. With the returnTVs property you can specify a comma separated list of TV values to retrieve, which you can then use in the tpl chunk.

      You'll need this snippet call:
      [[getRelated?
        &parents=`26` 
        &hideContainers=`1` 
        &fields=`pagetitle:3,introtext:2,tv.tags:5` 
        &returnTVs=`Factfile_title,Fact1`
        &rowTpl=`related_rowtpl`
      ]]


      Add a chunk named "realted_rowtpl" with this contents:
      <div class="entry">
      <h4><a href="[[~[[+id]]]]" rel="bookmark" title="Permanent Link to [[+pagetitle]]">[[+pagetitle]]</a></h4>
      <a href="[[~[[+id]]]]"><img class="alignleft" title="[[+Factfile_title]]" src="[[+Fact1:phpthumbof=`w=100&h=100&zc=1`]]" alt="" /></a>
      </div>


      On top of that, you'll probably also want to tweak the tplOuter property and pass it the name of a chunk to wrap all the related items in. See the docs: http://rtfm.modx.com/extras/revo/getrelated#getRelated-SnippetProperties
        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.
        • 7527
        • 437 Posts
        Hi Mark, thanks for the reply. I tried what you suggested but still just get a linked pagetitle but wit no image?
          www.PawsForWildlife.co.uk
          www.Borntobrick.co.uk
          • 7527
          • 437 Posts
          I have tried it exactly as you have said and still nothing other than the linked pagetitle. The TV Fact1 is an image, the input option is image and the output option text does that make a difference?

          DS
            www.PawsForWildlife.co.uk
            www.Borntobrick.co.uk
            • 7527
            • 437 Posts
            Looking at the page code this is what I see
            <h3>The following 2 pages may interest you as well:</h3>
            <ul>
              <li class="related0"><a href="index.php?id=37" title="(Ursus arctos horribilis)">(Ursus arctos horribilis)</a></li>
            
            <li class="related1"><a href="index.php?id=31" title="(Ursus arctos horribilis)">(Ursus arctos horribilis)</a></li>
            
            </ul>


            (They are named the same but purely for testing, they are two different pages ids 31 and 37).

            As mentioned the input and output options are different but they need to be for other reasons. My call is:

            [[getRelated?
              &parents=`26` 
              &hideContainers=`1` 
              &fields=`pagetitle:3,introtext:2,tv.tags:5` 
              &returnTVs=`Factfile_title,Fact1`
              &rowTpl=`related_rowtpl`
              &tplOuter=`related_outer`
            ]]


            with related_rowtpl as:

            <div class="newsblock">
            <div class="entry">
            <h4><a href="[[~[[+id]]]]" rel="bookmark" title="Permanent Link to [[+pagetitle]]">[[+pagetitle]]</a></h4>
            <a href="[[~[[+id]]]]"><img class="alignleft" title="[[*tv.Factfile_title]]" src="[[*tv.Fact1:phpthumbof=`w=100&h=100&zc=1`]]" alt="" /></a>
            </div>
            </div><!-- end newsblock -->


            and the related_outer as:

            <h3>[[%getrelated.pagesfound? &namespace=`getrelated` &count=`[[+count]]`]]</h3>
            <ul>
              [[+wrapper]]
            </ul>


            Sorry, I am trying to get used to all these new snippets
            DS
              www.PawsForWildlife.co.uk
              www.Borntobrick.co.uk
              • 7527
              • 437 Posts
              Fixed it. After rechecking the documentation, the &rowlTpl you mentioned:

              [[getRelated?
                &parents=`26` 
                &hideContainers=`1` 
                &fields=`pagetitle:3,introtext:2,tv.tags:5` 
                &returnTVs=`Factfile_title,Fact1`
                &rowTpl=`related_rowtpl`
              ]]


              is in fact &tplRow. Thanks once again for the help, it looks great now!
                www.PawsForWildlife.co.uk
                www.Borntobrick.co.uk