I am using taglister to print out a list of tags on a page. The client wants however a custom way to show the results. He does not want to just show a results list that getResourcesTag spits out but the following:
Each page that uses tags can be 1 of 3 possible templates. Each template has its own layout.
Also each result listed by getResourcesTag will show full content of this page.
I have templates with IDs of 4,5,6. Each one is assigned a layout.
I then made corresponding Chunks that shows the layout.
In my tpl for getResourcesTag, I am simply calling up my snippet and giving the snippet the ID of the resource
[[!getTagList? &id=`[[+id]]` &debug=`1`]]
The following code is my snippet getTagList:
$output='';
$criteria = $modx->newQuery('modResource');
$criteria->where(array(
'id' => $id,'published' => 1,
'deleted' => 0
));
$resource = $modx->getObject('modResource',$criteria);
$template=$resource->get('template');
switch($template){
case 4: $resourceArray=$resource->toArray();
$resourceArray['textblock2']=$resource->getTVValue('textblock2');
$resourceArray['image']=$resource->getTVValue('image.landscape');
$resourceArray['tags']=$resource->getTVValue('tags');
$resourceArray['image3']=$resource->getTVValue('image.portrait3');
$resourceArray['image4']=$resource->getTVValue('image.portrait4');
$output.=$modx->getChunk('landscapeTpl',$resourceArray);
break;
case 5: $resourceArray=$resource->toArray();
$resourceArray['textblock2']=$resource->getTVValue('textblock2');
$resourceArray['image1']=$resource->getTVValue('image.portrait1');
$resourceArray['image2']=$resource->getTVValue('image.portrait2');
$resourceArray['image3']=$resource->getTVValue('image.portrait3');
$resourceArray['image4']=$resource->getTVValue('image.portrait4');
$resourceArray['tags']=$resource->getTVValue('tags');
$output.=$modx->getChunk('portraitTpl',$resourceArray);
break;
case 6: $resourceArray=$resource->toArray();
$resourceArray['textblock2']=$resource->getTVValue('textblock2');
$resourceArray['textblock3']=$resource->getTVValue('textblock3');
$resourceArray['image1']=$resource->getTVValue('image.quad1');
$resourceArray['image2']=$resource->getTVValue('image.quad2');
$resourceArray['tags']=$resource->getTVValue('tags');
$output.=$modx->getChunk('quadratTpl',$resourceArray);
break;
};
if ($debug==1){
$output.="<div>template:".$template." id:".$id."</div>";}
return $output;
My problem is that sometimes during the loop, it cannot parse out the chunk. If I have debug set to 1, I can then see which template and which ID. These are always correct. So it just breaks out of the switch case and shows that data.
Can someone look at my code and see where and why it would sometimes not be able to parse out the code?
The chunks that it calls are following:
landscaptTpl
<article class="portfolio_wrapper clearfix">
<div class="portfolio_text">
<h2>[[+longtitle]]</h2>
[[+content]]
</div>
<aside class="tags">
[[!toLinks? &items=`[[+tags]]` &target=`13`]]
</aside>
<figure class="landscape">
<img src="[[+image:phpthumbof=`w=670&q=90`]]" alt="Landscape Bild" />
</figure>
[[+textblock2:notempty=`
<div class="portrait_float clearfix">
<div class="secondary_text">
[[+textblock2]]
</div>
`]]
[[+image3:notempty=`
<figure class="portrait3">
<img src="[[+image3:phpthumbof=`w=162&h=125&zc=1&q=90`]]" alt="Portrait 3" />
</figure>
`]]
[[+image4:notempty=`
<figure class="portrait4">
<img src="[[+image4:phpthumbof=`w=162&h=125&zc=1&q=90`]]" alt="Portrait 4" />
</figure>
`]]
[[+textblock2:notempty=`</div>`]]
</article>
portraitTpl
<article class="portfolio_wrapper clearfix">
<div class="portfolio_text">
<h1>[[+longtitle]]</h1>
[[+content]]
</div>
<aside class="tags">
[[!toLinks? &items=`[[+tags]]` &target=`13`]]
</aside>
<div class="portrait_images clearfix">
<figure class="portrait1">
<img src="[[+image1:phpthumbof=`w=330&h=470&zc=1&q=90`]]" alt="Portrait 1" />
</figure>
<figure class="portrait2">
<img src="[[+image2:phpthumbof=`w=330&h=470&zc=1&q=90`]]" alt="Portrait 2" />
</figure>
</div>
[[+textblock2:notempty=`
<div class="portrait_float clearfix">
<div class="secondary_text">
[[+textblock2]]
</div>
`]]
[[+image3:notempty=`
<figure class="portrait3">
<img src="[[+image3:phpthumbof=`w=162&h=125&zc=1&q=90`]]" alt="Portrait 3" />
</figure>
`]]
[[+image4:notempty=`
<figure class="portrait4">
<img src="[[+image4:phpthumbof=`w=162&h=125&zc=1&q=90`]]" alt="Portrait 4" />
</figure>
`]]
[[+textblock2:notempty=`</div>`]]
</article>
and quadratTpl
<article class="portfolio_wrapper clearfix">
<div class="portfolio_text">
<h2>[[+longtitle]]</h2>
[[+content]]
</div>
<aside class="tags">
[[!toLinks? &items=`[[+tags]]` &target=`13`]]
</aside>
<figure class="quad1">
<img src="[[+image1:phpthumbof=`w=333&h=333&q=90&zc=1`]]" alt="Quad 1" class="quad_image" />
<figcaption class="caption_quad1">
[[+textblock2]]
</figcaption>
</figure>
<figure class="quad2">
<img src="[[+image2:phpthumbof=`w=333&h=333&q=90&zc=1`]]" alt="Quad 1" class="quad_image" />
<figcaption class="caption_quad2">
[[+textblock3]]
</figcaption>
</figure>
</article>