The problem is that your tpl3th is not valid HTML. It has an unmatched closing div and an unmatched opening div.
Having invalid HTML in a Tpl chunk almost never works. I'm not sure what you're trying to do is possible with getResources because it doesn't have an &outerTpl property, which is what you need. No matter how you do it, a row with less than three items is going to have an unclosed div tag.
You could try doing it with Wayfinder, but I don't think it will set the TV placeholders (I could be wrong).
I would write a custom snippet to use instead of getResources. That would give you complete control of the output. You'd need, at minimum, an itemTpl chunk and a rowTpl chunk. Get it working on its own before using getPage with it.
This is not tested (though it might actually work), but it would look something like this:
portfolioRowTpl:
<!-- START ROW -->
<div class="portfolio-row">
[[+items]]
</div>
<div class="clear"></div>
<!-- END ROW -->
portfolioItemTpl (note: this is not the same as yours)
<!-- START ITEM -->
<div class="portfolio-item">
<div class="portfolio-image">
<a href="[[~[[+id]]]]"><img src="[[+tv.interactive-background-image]]:phpthumbof=`w=280&h=280&zc=1&aoe=0&far=0`" alt="[[+tv.main-content-title]]" class="fx7"/></a>
</div>
<div class="portfolio-caption">
<h4>[[+tv.main-content-title]]</h4>
</div>
</div>
<!-- ENDS ITEM -->
Snippet tag:
[[!MySnippet? &parent=`5` &limit=`6` &itemTpl=`portfolioItemTpl` &rowTpl=`portfolioRowTpl` &sortby=`createdon` &sortdir = `ASC`]]
Snippet (MySnippet):
<?php
$sp =&scriptProperties;
$parent = $modx->getOption('parents', $sp, 5);
$limit = $modx->getOption('limit', $sp, 6);
$sortby = $modx->getOption('sortby', $sp, 'createdon');
$sortdir = $modx->getOption('sortdir', $sp, 'ASC');
$itemTpl = $modx->getOption('itemTpl', $sp, 'portfolioItemTpl');
$rowTpl = $modx->getOption('rowTpl', $sp, 'portfolioRowTpl');
/* ******** You can delete this section once it's working ********/
$x = $modx->getChunk($itemTpl);
if (empty($x) ) {
return 'Cannot find itemTpl';
}
$x = $modx->getChunk($rowTpl);
if (empty($x) ) {
return 'Cannot find rowTpl';
}
/***************************************************************/
$c = $modx->newQuery('modResource');
$c->where( array (
'parent' => $parent,
'published' => '1',
'deleted' => '0',
));
$c->sortby($sortby, $sortdir); // might want publishedon instead
$c->limit($limit);
$resources = $modx->getCollection('modResource', $c);
if (empty($resources)) {
return 'No Resources found';
}
$rows = array_chunk($resources,3);
$output = '';
foreach ($rows as $row) {
$rowOutput = '';
foreach($row as $resource) {
$fields = array();
$fields['id'] = $resource->get('id');
$fields['tv.interactive-background-image'] = $resource->getTVValue('tv.interactive-background-image');
$fields['tv.main-content-title'] = $resource->getTVValue('tv.main-content-title');
$rowOutput .= $modx->getChunk($itemTpl,$fields);
}
$output .= $modx->getChunk($rowTpl, array('items' => $rowOutput) );
}
return $output;
If you need multiple parents in one tag, it gets more complicated, but not too much.
------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using.
MODX info for everyone:
http://bobsguides.com/modx.html
[ed. note: BobRay last edited this post 14 years, 4 months ago.]