Hello everyone. I was wondering if someone could give me assistance regarding the variable pair parsing.
I have read the docs, but have noticed a lot of $TMPL methods aren’t even mentioned there, and the example shown isn’t very helpful I have also tried looking through the amazon API, weblog module, and a few others as suggested in the docs, but they were a little to complex for me to understand.
Basically I have several arrays from which I need to insert into single variables that are between variable pairs. like so:
{exp:myPlugin:myMethod}
{var_pair_1}
{title}
{date}
{/var_pair_1}
{var_pair_2}
{something else}
{and another}
{/var_pair_2}
{/exp:myPlugin:myMethod}
so am I correct in saying that variable pairs are meant for looping? How do you control the looping?
I tried the following to get started:
$tagdata = $TMPL->tagdata //get everything between the main tags
foreach { $TMPL-var_pair as $key=>$val) //the var pair array
{ foreach( $myArray as $row ) //the content I want to use
{
if (ereg("^item", $key) //find the {item} tag
{
$tagdata = $TMPL->swap_var_single( 'title', $row['title'], $tagdata) //swap out the single variables
}
}
}
I know this is by no means correct, but im stuck! please help!
Vinci have you looked at the weblog entries tag categories pair code? Looking at that may give you some insight. Incidentally, we are aware that this issue is often hard for new EE developers to grasp, and I think you’ll be pleased with some of the developer’s tools we will be providing in 2.0.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.