variable pairs
Posted: 02 February 2008 08:08 PM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  180
Joined  06-04-2007

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!

Profile
 
 
Posted: 16 February 2008 11:13 AM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15845
Joined  06-03-2002

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.

 Signature 
Profile
MSG
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65024 Total Logged-in Users: 41
Total Topics: 82111 Total Anonymous Users: 24
Total Replies: 441280 Total Guests: 187
Total Posts: 523391    
Members ( View Memberlist )