<![CDATA[ getRelated: automatically listing related Resources for Revolution - MODX Community Forums]]> https://forums.modx.com/thread/?thread=71009 <![CDATA[Re: getRelated: automatically listing related Resources for Revolution]]> https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=9#dis-post-555458 aurorausa Nov 26, 2017, 08:06 AM https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=9#dis-post-555458 <![CDATA[Re: getRelated: automatically listing related Resources for Revolution]]> https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=9#dis-post-555457 aurorausa Nov 26, 2017, 08:05 AM https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=9#dis-post-555457 <![CDATA[Re: getRelated: automatically listing related Resources for Revolution]]> https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=9#dis-post-548793

Filtering by TV values indeed isn't possible. If you also mark them as hidden from menus when they expire, you could set
&includeHidden=`0`


Alternatively, you could use a snippet like getResources/pdoResources to get a comma separated list of IDs to ignore, and pass that into
&exclude
]]>
markh Feb 16, 2017, 12:39 PM https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=9#dis-post-548793
<![CDATA[Re: getRelated: automatically listing related Resources for Revolution]]> https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=9#dis-post-548203
Is there any way to filter out results based on a TV's value? I am using getRelated to show similar classes (the teacher/student kind of classes) and I would like to exclude all past classes from the results. I want to keep the past classes published, so they move to an archive page when the date of the class is over. It getResources, this is achieved with a simple snippet and TV filter:
&tvFilters=`classDate>>[[!todaysDate]]%`

But it doesn't seem like getRelated supports tv filters. Would it be possible to do something like this in getRelated? Show related classes as long as the date is in the future, and or hide related classes who's date has passed?

This is my first time using getRelated, and I'm loving it!

Thanks!]]>
chenrupo Jan 20, 2017, 09:32 AM https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=9#dis-post-548203
<![CDATA[Re: getRelated: automatically listing related Resources for Revolution]]> https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=8#dis-post-518315 Quote from: markh at Jan 11, 2015, 11:01 PM
Hi neiltipton!

You'll need to add the MIGX tv to your returnTVs property on the getRelated snippet first. I'm guessing Image, Alt and Caption are the fields within MIGX, however you'll need to grab the actual MIGX TV - not the fields within.

With that info, you can then use the MIGX included getImageList snippet to loop over the items in MIGX (if you just want the first, I think it accepts a &limit property) and output the image url.

Thanks Mark - I'll bear this in mind for the future. In the end, I realised I was overcomplicating things by using MigX in this instance - I ended up creating the fields with individual tvs and it works as anticipated and is probably more fit-for-purpose anyway. Great snippet nonetheless - I can't imagine how much time I would have spent trying to replicate something similar without it!]]>
neiltipton Jan 12, 2015, 08:22 AM https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=8#dis-post-518315
<![CDATA[Re: getRelated: automatically listing related Resources for Revolution]]> https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=8#dis-post-518275
You'll need to add the MIGX tv to your returnTVs property on the getRelated snippet first. I'm guessing Image, Alt and Caption are the fields within MIGX, however you'll need to grab the actual MIGX TV - not the fields within.

With that info, you can then use the MIGX included getImageList snippet to loop over the items in MIGX (if you just want the first, I think it accepts a &limit property) and output the image url.]]>
markh Jan 11, 2015, 05:01 PM https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=8#dis-post-518275
<![CDATA[Re: getRelated: automatically listing related Resources for Revolution]]> https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=8#dis-post-518274
How do I get an image stored as a MigX TV to display in my RowTpl? Currently It's unable to find the image url, alt text and title.

This is my getrelated call:
[[getRelated?
    &limit=`3`
    &parents=`303`
    &fields=`pagetitle:10,tv.article_tags:7,introtext:5`
    &tplOuter=`RCI.RelatedOuter`
    &tplRow=`RCI.RelatedRow`
    &returnTVs=`Image,Alt,Caption`
    ]]


And this is my RCI.RelatedRow:

<li>

<div class="related-image">
<a href="[[~[[+id]]]]"><img src="[[+Image:phpthumbof=`w=200&h=134&zc=1`]]" alt="[[+Alt]]" title="[[+Caption]]" /></a>
</div>

<div class="related-text">
<a href="[[~[[+id]]]]">[[+longtitle:default=`[[+pagetitle]]`]]</a>

</div>

 </li>


I'm guessing I need to run a getResources call to get the info for the Tvs that getRelated needs first, but how exactly do I incorporate this into RowTpl? I am having a bit of blank moment here (been a looooong day!)]]>
neiltipton Jan 11, 2015, 04:58 PM https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=8#dis-post-518274
<![CDATA[Re: getRelated: automatically listing related Resources for Revolution]]> https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=8#dis-post-512916

]]>
markh Oct 17, 2014, 03:09 PM https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=8#dis-post-512916
<![CDATA[Re: getRelated: automatically listing related Resources for Revolution]]> https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=8#dis-post-512914 viktorminator Oct 17, 2014, 03:05 PM https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=8#dis-post-512914 <![CDATA[Re: getRelated: automatically listing related Resources for Revolution]]> https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=8#dis-post-512906
From the documentation:

Resource field to sort by in collecting the sample, used in conjunction with the fieldSample propert. (Does not sort the related resources output, only the sample used in determining related resources!)

It only affects the sample; getRelated automatically sorts based on the the calculated rank for each result. The fieldSort property is useful when you have a really large set of resources with a lot of matches and you run into the sample limit.

If you just want to show recent posts with a certain tag, use getResourcesTag (part of the TagLister extra).]]>
markh Oct 17, 2014, 02:27 PM https://forums.modx.com/thread/71009/getrelated-automatically-listing-related-resources-for-revolution?page=8#dis-post-512906