<?php
$q_chunks = $modx->db->query('
SELECT
chunk.*
FROM '.$modx->getFullTableName('site_htmlsnippets').' AS chunk
INNER JOIN '.$modx->getFullTableName('categories').' AS category
ON chunk.category = category.id
WHERE
category.category IN ("'.$category.'")
ORDER BY
name
');
$ar_chunks = array();
while ($row = $modx->db->getRow($q_chunks)) {
$ar_chunks[] = $row['name'];
}
$l_chunks = implode("||",$ar_chunks);
return $l_chunks;
?>
<?php
$ar_chunks = split(',',$chunks);
$ar_chunks = array_unique($ar_chunks);
$output = '';
foreach ($ar_chunks as $chunk) {
if ($chunk != '') {
$c = $modx->getChunk($chunk);
if ($c) $output .= $c;
}
}
if ($output != '' && isset($wrapperdiv)) {
$output = '<div id="'.$wrapperdiv.'">'.$output.'</div>';
}
return $output;
?>
$c='{{'.$chunk.'}}';$c=$modx->parseDocumentSource( '{{'.$chunk.'}}');« MODx Parse Error »
MODx encountered the following error while attempting to parse the requested resource:
« PHP Parse Error »
PHP error debug
Error: Invalid argument supplied for foreach()
Error type/ Nr.: Warning - 2
File: /var/www/vhosts/theclubandspachester.co.uk/httpdocs/assets/snippets/ditto/classes/template.class.inc.php
Line: 50
Line 50 source: foreach ($templates as $tplName=>$tpl) {
Parser timing
MySQL: 0.0018 s (10 Requests)
PHP: 0.0640 s
Total: 0.0658 s
seems the array-count of $templates is cero at this point.
can you show us your chunkcontent where you have your ditto-call
[!Ditto?startID=`2` &tpl=`latest-news-side` &extenders=`summary` &display=`2` &sortBy=`pub_date` &sortDir=`desc` &dateSource=`pub_date` &dateFormat=`%d %b %y` &paginate=`0`!]
<div class="list-item-row"> <div class="list-item-image">[+list-image+]</div><!-- / list-item-image --> <div class="list-item-detail"> <h3><a href="[~[+id+]~]" title="[+title+]">[+title+]</a></h3> [+summary+] <a href="[~[+id+]~]" title="Read more about [+title+]">Read more »</a> </div><!-- / list-item-detail --> </div><!-- / list-item-row -->
<?php
$ar_chunks = split(',',$chunks);
$ar_chunks = array_unique($ar_chunks);
$output = '';
foreach ($ar_chunks as $chunk) {
if ($chunk != '') {
$c = $modx->getChunk($chunk); /*** now string $c contains chunk's content -> raw mix of html and modx tags ***/
/*** now it is a time to parse snippet tags in string $c ***/
$c = $modx->evalSnippets($c); /*** yeah! done! ***/
/*** of course, it might be done with a single step :)
$output .= $modx->evalSnippets($modx->getChunk($chunk));
important notice: evalSnippet function recognizes only cached version of snippets [[...]]
***/
if ($c) $output .= $c;
}
}
return $output;
?>
I love this code, but can’t figure out a way to set the order of the included chunks. Any ideas/suggestions? The current ordering is simply by chunk name. I would like to be able to control this per page via TVs, or...???
Add widgets to Manager fields - e.g. Del.icio.us-like tag interface, color picker, image previewWith a bit of jquery and show the chunks as tags that are clicked to add them to the text box?