I’m writing my first plugin (EE 2.1) and it accepts a single parameter that is supposed to be the current member_id. However, when I do <ext:my_plugin:my_func my_param=”{member_id}”> I literally get the string “{member_id}” and not the numeric value from $this->EE->TMPL->fetch_param(‘my_param’). I also tried using an open/close tag, but I get the same behavior from $this->EE->TMPL->tagdata. I’ve tried eliminating quotes around the tag and using single quotes. {member_id} does evaluate correctly when used in the template proper.
Do I have to do something special to tell EE to evaluate tags passed as parameters to a plugin? The plugin docs do it all over the place and seem to imply that it should work fine.
Thanks for any help!
Thanks for the quick response. Passing a hard-coded member id (like “18”) works fine and the plugin function returns the appropriate result. But passing “{member_id}” results in the function getting “{member_id}” instead of “18”. However, when I do <h1>{member_id}</h1> in my template then I get <h1>18</h1> as expected, so the {member_id} variable does work.
I’m brand new to EE. Is there maybe a setting somewhere that I need to tweak that controls nested tag evaluation?
Thanks!
It’s a parse order issue (your plugin is being parsed before member_id).
You can change the parse order of plugins using parse=”inward”, as described at the bottom of this page.
However, if you’re looking the current member id, you’re best off just grabbing it from the session:
$member_id = $this->EE->session->userdata('member_id');I’m having this problem as well. I’m writing a plugin that returns weather info for a given location. When I hard code the location into the tag, it works fine. For example
{exp:weather:current location="94158"}I’ve setup a global variable called “site_location”. When I use the global var in the parameter, it doesn’t work anymore. In the plugin, I’m getting {site_location}. I’ve tried setting the parse order, but that did not help.
Any help would be appreciated.
Thanks, daniel
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.