Displaying a User's Information After Hes Logged In |
[eluser]JayArias[/eluser]
I'm running into a bit of a problem. I LOVE code igniter with capital letters but, it has it's downs and those are that I can never get how to globally display a logged in users information I've tried Quote: @Colin Williams I've also just tried Code: $this->template->write_view('content', 'templates/admin/content', $data); ![]() ![]() Therefore I have had to turn around and use another php framework that is not mvc which I HATE. Can some one please help me, I already now how to get the user to sign in I just need to call their information from the model. I don't want to use 3rd party code as the code I wrote I already know what it does and I don't have to append things here and there, but it's always and option. Long story short... Some one please help me :'(
[eluser]Ben Edmunds[/eluser]
Your problem isn't CodeIgniter or MVC, you're not understanding/using MVC correctly. Say you have a users_model with a method called get_user($user_id) that returns the user object with Code: return $query->result(); In your controller you can do Code: $this->load->model('users_model'); Then in your view you have the complete user object available. If you need it need it on every view you can use a MY_Controller or something similar.
[eluser]JayArias[/eluser]
I completely understand what you're saying and .. well thats how I am set up currently. The only problem is that if needed I can't echo anything else to that View . hence: Code: $this->load->model('users_model'); I will be SOL if I needed to do the following Code: $this->load->model('messages');
[eluser]Ben Edmunds[/eluser]
No you won't. Use $this->data instead of $data, So Code: $this->data['user'] = $this->users_model->get_user($user_id); and Code: $this->data['messages'] = $this->pm_model->get_last10(); and don't write the view until you have everything you need in $this->data. Then once you have everything do Code: $this->template->write_view('content', 'templates/admin/content', $this->data);
|
Welcome Guest, Not a member yet? Register Sign In |