<![CDATA[ excluding list of resources from getResources call as fetched from TV - My Forums]]> https://forums.modx.com/thread/?thread=104630 <![CDATA[excluding list of resources from getResources call as fetched from TV]]> https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv?page=2#dis-post-562748
So fetchedLIST TV will output: 1,12,34,78 for example - these being the IDs of the resources to ignore in the getResources call

So, in effect a way of having resources=`-[[*fetchedLIST]]` but needing to add a - before EACH of the IDs returned by TV fetchedLIST

So if I had resources in the parent resource 12 with ids: 1,2,3,4,12,34 and 78

I would want my getResources call to just display those from the group above, that ARE NOT included in the fetchedLIST TV - so not 1,12,34 and 78 - so the output of the getresources call would be the data for JUST resources ID: 2,3 and 4


]]>
dubbs Nov 15, 2018, 11:41 AM https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv?page=2#dis-post-562748
<![CDATA[Re: excluding list of resources from getResources call as fetched from TV]]> https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv#dis-post-562793 BobRay Nov 16, 2018, 11:08 PM https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv#dis-post-562793 <![CDATA[Re: excluding list of resources from getResources call as fetched from TV]]> https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv#dis-post-562766 dubbs Nov 15, 2018, 10:08 PM https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv#dis-post-562766 <![CDATA[Re: excluding list of resources from getResources call as fetched from TV (Best Answer)]]> https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv#dis-post-562765 Snippet code as below works wink

Snippet Name: getfetchedList

$page = $modx->getObject('modResource', 48);
$docs = $page->getTVValue('fetchedLIST');
$docs = str_replace(",", ",-", $docs);
echo $docs;


And getResources call for those looking to do similar...

[[!getResources? &parents=`49` &tpl=`elementTpl` &depth=`1` &limit=`9999999999` &includeTVs=`1` &processTVs=`0` &tvPrefix=`` &sortby=`RAND()` &showHidden=`1` &resources=`-[[!getfetchedList]]` ]]
]]>
dubbs Nov 15, 2018, 10:07 PM https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv#dis-post-562765
<![CDATA[Re: excluding list of resources from getResources call as fetched from TV]]> https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv#dis-post-562764 so no server error now - but it doesnt work for some reason still fetches all results?]]> dubbs Nov 15, 2018, 09:55 PM https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv#dis-post-562764 <![CDATA[Re: excluding list of resources from getResources call as fetched from TV]]> https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv#dis-post-562763 Quote from: BobRay at Nov 15, 2018, 06:29 PM
I think this might do it:


&resources = `-[[GetFetchedList]]`


/* GetFetchedList snippet */
$docs = $modx->resource->getTVValue('fetchedLIST');
return str_replace(','. ',-', $docs);


The snippet result will be cached, so it probably won't work correctly if the getResources tag is on multiple pages where the TV has different values. In that case, I think an uncached custom snippet that either gets the resources directly (best if the getResources tag is simple) or calls getResources with $modx->runSnippet() would work.

I could probably knock it out for you if I can see your full getResources tag.

Thanks Bob - for some reason I get a blank page when I add this code in - server error in the code somewhere? Error seems to be in snippet - as page renders when i clear snippet code?

getResources code call is:

[[getResources? &parents=`49` &tpl=`ItemTpl` &depth=`1` &limit=`9999999999` &includeTVs=`1` &processTVs=`0` &tvPrefix=`` &sortby=`RAND()` &showHidden=`1` &resources=`-[[GetFetchedList]]` ]]
]]>
dubbs Nov 15, 2018, 09:41 PM https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv#dis-post-562763
<![CDATA[Re: excluding list of resources from getResources call as fetched from TV]]> https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv#dis-post-562758

&resources = `-[[GetFetchedList]]`


/* GetFetchedList snippet */
$docs = $modx->resource->getTTValue('fetchedLIST');
return str_replace(','. ',-', $docs);


The snippet result will be cached, so it probably won't work correctly if the getResources tag is on multiple pages where the TV has different values. In that case, I think an uncached custom snippet that either gets the resources directly (best if the getResources tag is simple) or calls getResources with $modx->runSnippet() would work.

I could probably knock it out for you if I can see your full getResources tag.
]]>
BobRay Nov 15, 2018, 06:29 PM https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv#dis-post-562758
<![CDATA[Re: excluding list of resources from getResources call as fetched from TV]]> https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv#dis-post-562752 Quote from: chrisandy at Nov 15, 2018, 04:07 PM
I'd have thought you'd use &parents rather than &resources and then apply the 'where'. I'm not sure what the syntax would be for the query though, especially with a custom tv - maybe you'll need a snippet?

I use the parents to set the resource parent which holds the resources to be fetched - then use the resources to specify which to remove/display.

Anyone any ideas on the syntax to use to get the where parameters to work? There is very little documentation illustrating this?]]>
dubbs Nov 15, 2018, 04:10 PM https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv#dis-post-562752
<![CDATA[Re: excluding list of resources from getResources call as fetched from TV]]> https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv#dis-post-562751 chrisandy Nov 15, 2018, 04:07 PM https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv#dis-post-562751 <![CDATA[Re: excluding list of resources from getResources call as fetched from TV]]> https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv#dis-post-562750 Quote from: chrisandy at Nov 15, 2018, 02:17 PM
Could you use 'where' query? In effect something like...

$query->where(array(‘id:!=‘ => array([[*fetchedLIST]])));


https://docs.modx.com/xpdo/2.x/class-reference/xpdoquery/xpdoquery.where

Theory sounds good - how would that get pushed into the &resources field of getResources though?]]>
dubbs Nov 15, 2018, 03:21 PM https://forums.modx.com/thread/104630/excluding-list-of-resources-from-getresources-call-as-fetched-from-tv#dis-post-562750