We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

variable pairs

Development and Programming

vinci's avatar
vinci
85 posts
17 years ago
vinci's avatar vinci

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!

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

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.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.