Hi, I am trying to do this with my module template:
{exp:gradee class_id='1' student_id='{member_id}'}
When I do that, I don’t get any results. It seems the module runs before I am able to get that member_id.
Does anyone know how I can fix this? When I hard code in a member id it works fine, but I need to be able to display grades for a specific students, depending on who is logged in.
Thanks! Zac
When I do that, I don’t get any results. It seems the module runs before I am able to get that member_id.
I had the same problem so I did the following:
function _get_member_id()
{
global $TMPL, $SESS;
$member_id = $TMPL->fetch_param('member_id');
if($member_id == FALSE || $member_id == '{member_id}' || $member_id == '{logged_in_member_id}')
$member_id = $SESS->userdata['member_id'];
if(is_numeric($member_id))
return $member_id;
else
return "";
}
Essentially if I don’t get a member id or the string is set to {member_id} (i.e. the variable has not be resolved) then I grab the member id from the session, effectively resolving the variable.
You could always grab the member_id from the session but I find this to be more flexible as it allows me to set a specific member id, e.g. for testing.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.