Welcome Guest, Not a member yet? Register   Sign In
Pass $data array element from MY_Controller to view
#1

[eluser]Unknown[/eluser]
I'm probaly being a div but I wondered if anyone can recommend a way I can populate a view from MY_Controller.
What I want really is a login form on every page if they're logged. User menu if they're not. Easy probaly.

Code:
class  MY_Controller  extends  Controller  {

    function MY_Controller ()  {
        parent::Controller();
        $this->load->library('tank_auth');
        if (!$this->tank_auth->is_logged_in()) {
            $data['login'] = 'login';
             something here
        } else {
            $data['user_id']    = $this->tank_auth->get_user_id();
            $data['username']    = $this->tank_auth->get_username();
            $data['login'] = 'notifications';
            something here
            
        }

    }
}

and the view file

Code:
<div id = "logo" class = "span-11">
<h1>Logo</h1>
</div>
<div id = "search" class = "span-13 last">
</div>
<div id = "log_in" class = "span-13 last">
<p class = "strong last">&lt;?php $this->load->view($login); ?&gt;</p>
</div>

dont worry sussed it, just used vars.
#2

[eluser]flaky[/eluser]
I'd recommend you to use Template Library
http://www.williamsconcepts.com/ci/codei.../template/

this way you can configure your default regions and which region what to display




Theme © iAndrew 2016 - Forum software by © MyBB