Welcome Guest, Not a member yet? Register   Sign In
Helper Question
#1

[eluser]JayArias[/eluser]
I was just figuring.. if I made a helper to display user information globally basically saying.

Code:
$this->user->information('first_name')
will display the logged in user's first name.

would it work? Is there any other way to display user information with out having to use a model?
#2

[eluser]Colin Williams[/eluser]
I don't think you need a "getter" for every little data object. And I'm not sure why you want to avoid a model? Embrace the Holy Trinity Smile

Consider this code in a Controller constructor:

Code:
$this->load->model('user_model');
$this->load->vars('cur_user', $this->user_model->get_current_user);
// Imagine get_current_user() returning either a user object
// from the database or a dummy object of an anonymous user.

Now the variable $cur_user is available to all of your views, so you can echo it anywhere

Code:
<h2>&lt;?php print $cur_user->first_name ?&gt;</h2>
#3

[eluser]JayArias[/eluser]
Yeah... this isn't working if I could get this to work I would be golden.




Theme © iAndrew 2016 - Forum software by © MyBB