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
??
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…
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.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.