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

tag parsing issues

Development and Programming

Badlands's avatar
Badlands
17 posts
16 years ago
Badlands's avatar Badlands

Hi, could someone please help me understand why this array

Array ( 
[0] => 
        Array ( 
                [member_id] => 2 
                [screen_name] => Woman 
                [photo_filename] => photo_2.jpg ) 
[1] => Array ( 
                [member_id] => 1 
                [screen_name] => Man 
                [photo_filename] => photo_1.jpg ) 
)

(which is held in the $variables variable)

Followed by

return $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $variables);

Would be repeating key 0 twice?

So in my template tags its displayig

{member_id} as 2 {screen_name} as Woman {photo_filename} as photo_2.jpg

then the next iteration displays the same variables

{member_id} as 2 {screen_name} as Woman {photo_filename} as photo_2.jpg

instead of the expected

{member_id} as 1 {screen_name} as Man {photo_filename} as photo_1.jpg

??

       
TKoorn's avatar
TKoorn
64 posts
16 years ago
TKoorn's avatar TKoorn

what does the template say? What does the loop look like?

       
Badlands's avatar
Badlands
17 posts
16 years ago
Badlands's avatar Badlands

This is on the template

{exp:rsvp:attendee_list event_id="{entry_id}" show="public_only"}
    <a href="http://{site_url}index.php/member/{member_id}" class="align_left">_             {site_url}images/member_photos/{photo_filename}_        </a>
        <h4><a href="http://{site_url}index.php/member/{member_id}">{screen_name}</a></h4>{/exp:rsvp:attendee_list}

This is the function in rsvp class

function attendee_list(){

    $this->EE->load->library('parser');

    $event_id    =    $this->EE->TMPL->fetch_param('event_id');
        

    $this->EE->db->select('exp_members.member_id, screen_name, photo_filename');
    $this->EE->db->from('exp_rsvps');
    $this->EE->db->join('exp_members', 'exp_members.member_id = exp_rsvps.member_id');
    $this->EE->db->where('event_id', $event_id);

    //If the {exp:rsvp:attendee_list} tags have a the show parameter set to public only, we only retrieve the ones with a public status
    if($this->EE->TMPL->fetch_param('show') == 'public_only')
    {
        $this->EE->db->where('status', 'public');
    }
            
    $query        =        $this->EE->db->get();
        
     if( ! $query->result_array())
    {
        return "No one has registered to attend this event. Get the ball rolling";
        }        
        
        $x = $query->result_array();

    $variables = array(); 
    foreach($x as $block => $row ) 
    { 
            
        $variables[$block] = array();
            
        foreach($row as $label => $value)
        {            

            $variables[$block][$label]    =    $value;
        } 
        
          return    $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $variables); 
    }

}

Cheers…

       
TKoorn's avatar
TKoorn
64 posts
16 years ago
TKoorn's avatar TKoorn

there is a danger when using member_id and screen_name etc. variables in your pluging because these variables can get set outside of your plugin. When you are logged in these can get set to the logged in user’s values which can be very confusing in debugging. So just to be safe I would for debugging purposes select them using “as”.

$this->EE->db->select('exp_members.member_id as rsvp_member_id, screen_name as rsvp_screen_name, photo_filename as rsvp_photo_filename');

The code looks fine, the plugin code looks fine. So either there is something going wrong so that the entry_id parameter isn’t correct, or something is wrong in the database that makes the join not work properly. If you have 2 different records in the database and the output is identical then either the template is showing the logged in users data in stead of the actual data or it is showing data for the wrong record.

That is all I can think of at this point, I hope it helps in some way.

       
Badlands's avatar
Badlands
17 posts
16 years ago
Badlands's avatar Badlands

Thanks heaps mate, I’ll go over it in the morning and let you know how I get on.

       
Badlands's avatar
Badlands
17 posts
16 years ago
Badlands's avatar Badlands

Perfect. Thank you TKoorn. This is exactly what the problem was.

       

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.