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

Question about parse order for module template

Development and Programming

Zac G.'s avatar
Zac G.
268 posts
16 years ago
Zac G.'s avatar Zac G.

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

       
Benoît Marchal's avatar
Benoît Marchal
204 posts
16 years ago
Benoît Marchal's avatar Benoît Marchal
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.

       
Zac G.'s avatar
Zac G.
268 posts
16 years ago
Zac G.'s avatar Zac G.

I finally got back into my grading app and got to try this out. Worked like a charm, cheers 😊

       

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.