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

Setting user variables for use in templates

Development and Programming

KPowell's avatar
KPowell
7 posts
16 years ago
KPowell's avatar KPowell

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.

       
KPowell's avatar
KPowell
7 posts
16 years ago
KPowell's avatar KPowell

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.

       

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.