Hi,
I was wondering if there is a way without going directly into the core template file to add global user variables for templates. Let’s say that I have a completely separate table for a module I made that holds other user information such as preferences, name, etc. So, I could use something like {full_name} instead of something like {exp:module:full_name}. As there are no hooks in the template file, is there some other way to do this? I’d much rather use the session class to set variables than load my module on every single page.
I know I could use use the { exp:member:custom_profile_data } tag, but why would I want to do that on every page if I just want to display their name so they know they are logged in?
Thanks for any help.
ok, I solved this by using the sessions_end hook. Looks something like:
function add_session_vars($SESS)
{
global $IN;
$IN->global_vars['full_name'] = $SESS->userdata['full_name'];
}
$IN->global_vars is filled from the path.php file. I’m just using that variable to fill in what I want to add from the extension, so I don’t have to worry about adding it there. I hope this helps someone else along the way. Took a bit of searching to get that right.
Also, if anyone is interested, I set what I wanted in a cookie first, and used the sessions_start hook to put it back in the session. Then I check for those session variables before I do another lookup.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.