getResources not working properly with snippet
I use getResources along a tpl that includes a snippet. Problem is that getresources gives mixed/wrong results.
My getResource call:
The TPL:
The SNIPPET:
My getResource call:
[[!getPage?
&elementClass=`modSnippet`
&element=`getResources`
&parents=`219`
&cache=`false`
&tpl=`MATCH_INDEX_FREE_TPL`
&showUnpublished=`0`
&showHidden=`1`
&includeContent=`1`
&limit=`5`
&processTVs=`1`
&includeTVs=`1`
&depth=`25`
&sortby=`createdon`
&sortdir=`DESC`
&pageNavVar=`page.nav`
]]The TPL:
[[!IMAGE_PATH? &docid=`[[+id]]`]]
<div class="dog_cont">
<div class="data_title_new">[[+tv.Race]]</div>
<div class="dog_photo2">
<div id="ad_image_big"><a href="[[!+path1:phpthumbof=`w=900&zc=t`]]" rel="lightbox"><img src="[[!+path1:phpthumbof=`w=200&h=160&zc=t`]]" /></a></div>
<div id="ad_image_small" ><a href="[[!+path2:phpthumbof=`w=900&zc=t`]]" rel="lightbox"><img src="[[!+path2:phpthumbof=`w=95&h=80&zc=t`]]" /></a></div>
<div id="ad_image_small2"><a href="[[!+path3:phpthumbof=`w=900&zc=t`]]" rel="lightbox"><img src="[[!+path3:phpthumbof=`w=95&h=80&zc=t`]]" /></a></div>
</div>The SNIPPET:
<?php
$docid = $modx->getOption('docid',$scriptProperties,$modx->resource->get('id'));
if ($resource = $modx->getObject('modResource',$docid)){
$values = explode(',',$resource->getTVValue('IMAGE'));
$i = 1;
foreach ($values as $value){
$modx->setPlaceholder('path'.$i,$value);
$i++;
}
}
return ''; Комментарии: 6
Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
Or you could try to use pdoResources with &prepareSnippet that will additionally process each row:
Snippet getMyImages:
Now you can use placeholders in chunk:
No need to make them uncacheable, by the way.
There could be a misunderstanding with letters case of your placeholders, but you can see them all if you will specify a blank &tpl=`` property.
pdoPage and pdoResources is the parts of pdoTools package.
Thank you!
IMAGE_PATH
I used Василий way and since it works so well I leave that.