Let's say you have some data and want to use a chunk for display... Up until now you had several round-about ways to display a resultset in a chunk... You either had to pre-process the data and send it as a variable to the chunk, or you had to send a row chunk to mergeCodeVariables() using a loop in your snippet... Sure, 90% of what I just said makes no sense at all... But some of you get it... I'll break it down further...
Using parseChunk() goes something like this... You make an API function call something like:
// Snippet: myExample
$output = $etomite->parseChunk("myExample", array('title'=>'My Chunk', 'content'=>'The content I want displayed here.'), "{", "}");
return $output;<!-- Chunk: myExample -->
<h1>{title}</h1>
<div>
{content}
</div>The code above serves as a basic example of how parseChunk() works... Or at least how it has always worked up until now... The code below is an example of how the added looping feature works...// Snippet: newExample
$rs = $etomite->getActiveChildren(0);
$output = $etomite->parseChunk("newExample", array('title'=>'New Example', 'rows'=>$rs));
return $output;<!-- Chunk: newExample -->
<table>
<caption>{title}</caption>
{rows}
<tr>
<td>{pagetitle}</td><td>{description}</td>
</tr>
{/rows}
</table>What you will notice is that it is now possible to send an array as a value to parseChunk() and it will be processed by looping through the array and each iteration will process the tags within a tag pair, in this case that pair being {rows}{/rows}...Now, surely I'm not the only person that something like this excites... But, then again, you probably can't see the benefits without playing with the code... Well, I am willing to let a select few people test the modified function... PM me if you want to see how it works... Here is a link to an example on my development site...











