<![CDATA[ Synchronize 2 Getresources Calls - MODX Community Forums]]> https://forums.modx.com/thread/?thread=102086 <![CDATA[Synchronize 2 Getresources Calls]]> https://forums.modx.com/thread/102086/synchronize-2-getresources-calls#dis-post-550186 dylanwood Apr 21, 2017, 09:32 PM https://forums.modx.com/thread/102086/synchronize-2-getresources-calls#dis-post-550186 <![CDATA[Re: Synchronize 2 Getresources Calls]]> https://forums.modx.com/thread/102086/synchronize-2-getresources-calls#dis-post-550317
You might consider turning things around by getting the resource list inside the snippet without the overhead of another getResources call (untested).

[[!randomauthorgenerator? &parents=`99`]]



 $c = $modx->newQuery('modResource');
 $c->limit(3);
 $c->where(array('parent' => $parents));
 $c->sortby('RAND()');

 $docs = $modx->getCollection('modResource', $c);
 $rsetArray = array();
 foreach($docs as $doc) {
      $rsetArray[] = $doc->get('id');
 }
 $rset = implode(',', $rsetArray());

 return '
<div id="auther-slider-thumb" class="auther-slider-thumb">


[[!getResources? &resources=`'.$rset.'` &includeContent=`1` &includeTVs=`1` &processTVs=`1` &tvPrefix=`` &tpl=`AuthorImg`]]


</div>
<ul class="auther-slider">
[[!getResources? &resources=`'.$rset.'` &includeContent=`1` &includeTVs=`1` &processTVs=`1` &tvPrefix=`` &tpl=`AuthorDetail`]]

</ul>
';



]]>
BobRay Apr 27, 2017, 03:33 PM https://forums.modx.com/thread/102086/synchronize-2-getresources-calls#dis-post-550317
<![CDATA[Re: Synchronize 2 Getresources Calls]]> https://forums.modx.com/thread/102086/synchronize-2-getresources-calls#dis-post-550305
Outer call from template:
[[!randomauthorgenerator? &rset=`[[!getResources? &parents=`99` &limit=`3` &sortby=`rand()` &tpl=`@INLINE [[+id]],`]]`]]

Inside the snippet:

<?php
echo '
<div id="auther-slider-thumb" class="auther-slider-thumb">


[[!getResources? &resources=`'.$rset.'` &limit=`3` &includeContent=`1` &includeTVs=`1` &processTVs=`1` &tvPrefix=`` &tpl=`AuthorImg`]]


</div>
<ul class="auther-slider">
[[!getResources? &resources=`'.$rset.'` &limit=`3` &includeContent=`1` &includeTVs=`1` &processTVs=`1` &tvPrefix=`` &tpl=`AuthorDetail`]]

</ul>
';
]]>
dylanwood Apr 26, 2017, 04:27 PM https://forums.modx.com/thread/102086/synchronize-2-getresources-calls#dis-post-550305
<![CDATA[Re: Synchronize 2 Getresources Calls]]> https://forums.modx.com/thread/102086/synchronize-2-getresources-calls#dis-post-550189
Call the snippet uncached once at the top of the page, then use the TV value in the &offset property of getResources. The images will be in order from the offset value -- I don't think you can randomize the 5, but they'll be taken from a random part of the table.

Another way, if it would work for you, would be to use the &toPlaceholder property to have the results written to a placeholder, then use that placeholder in both places.
]]>
BobRay Apr 21, 2017, 09:43 PM https://forums.modx.com/thread/102086/synchronize-2-getresources-calls#dis-post-550189