This is my first posting. i’ve being play around with modx try to find out if it suitable for redeveloping my site. I’m not an expert at php but, with difficult I can put bits together.
I’ve try to output a snippet using a chuck as a template. The chuck was being outputted within a loop, the problem was that it only replaces the placeholder with the last in the loop. I know it has something to do with the loop finishing before the snippet is parse. I found the posting:
http://modxcms.com/forums/index.php/topic,12127.msg80789.html#msg80789
but can not get it to work: this is what I have
Chunk Code
-------------------------------------------------------------------
<div class="uv_listings2">
<img src="[+ls_img_src+]" width="216" height="144" alt="" border="0">
<h4>[+ls_page_title+]</h4>
<p>
[+ls_page__intro+]
<strong>More info on: <a href="#">[+ls_page_title+]</a></strong>
</p>
<h6>PRICE:</h6>
</div>
-------------------------------------------------------------------
Snippet code (top half borrowed from getChildIds snippets) and has been inserted as [[snippetName]]
-------------------------------------------------------------------
$docid = (isset($docid))? $docid: $modx->documentIdentifier;
$children= $modx->getActiveChildren($docid, ’menuindex’, ’ASC’,’id’);
if (!$children === false) {
$idArray = array();
foreach ($children as $c)
{
$idArray[] = $c[’id’];
}
//$output = implode(’,’,$idArray);
$output = $idArray;
} else {
$output= $docid;
}
$nmOutput.= "";
foreach ($output as $id)
{
$tvPagetitleArray = $modx->getTemplateVarOutput(’pagetitle’, $id, 1 );
$tvIntrotextArray = $modx->getTemplateVarOutput(’introtext’, $id, 1 );
$nmImageSrc = "assets/images/costa-rica/listings-pholder2.jpg";
$chunkArr = array(
’ls_page_title’ => $tvPagetitleArray[’pagetitle’],
’ls_page__intro’ => $tvIntrotextArray[’introtext’],
’ls_img_src’ => $nmImageSrc
);
$nmOutput .= $modx->parseChunk(’recordList’, $modx->placeholders, ’[+’, ’+]’);
} // end for loop
echo $nmOutput;
-------------------------------------------------------------------
Nothing gets outputted! I’m new to this stuff so do not know where start looking.
does ’$modx->parseChunk’ output an array or string? and if so how do I access it!
Is there an easier way to do this or am i missing something. Basically i’m try to layout the children of a current page as a listing with title, link and image to the actual page.
Sorry for such a long post, any help appreciated
using version 0.9.6.1
Thanks