Welcome Guest, Not a member yet? Register   Sign In
How i can load a controller in a sidebar
#1

[eluser]Unknown[/eluser]
Hi all, excuseme if a make a mistake, because i don't speak english very well (sorry i am learning) this is my problem

Mi website have ( head, body (post &sidebarWink and footer.

So, when i used any controller i load the next views

Code:
$this->load->view('head&body;');
$this->load->view('viewOfMyController');
$this->load->view('sidebar&footer;');

hear, i don't have any problem, but yesterday y make a controller for the administration of users, the name is 'User', so ,this controller have a view shows a form (if the user is not login) or a menu (is the user is login).
So, i need this controller always is in the sidebar, but i am not sure how i can do that, because, from the view i can't call a controller, and from other controller i can't call controller i try this

Code:
$this->load->view('head&body;');
$this->load->view('viewOfMyController');
$[color=red]this->load->controller('User');[/color]
$vform=$this->User->showForm();[color=gray]//in this part i return the view ($this->load->view('form',"",true);[/color]
$this->load->view('sidebar&footer;',$vform);


but as you know, i can't do this, $this->load->controller('User');
so, guya what i can do ? maybe i need make a library? i am not sure Thanks for your time, and excuseme for my mistakes
#2

[eluser]Glazz[/eluser]
I recomend you to have a sidebar view, and in that sidebar view you have some logic to check if the user is logged in or not.

Code:
$data['is_logged'] = 'true or false'; // here you need to have your own logic, so that you know if the user is logged in or not...

// show the sidebar, and send the information needed...
$this->load->view('sidebar', $data);


sidebar.php ( view )
Code:
if($is_logged)
{
// here you show the menu
// you can call $this->load->view('sidebar_menu'); for example
} else {
// user is not logged in so we show the form
// $this->load->view('sidebar_form');
}

Something like this...
#3

[eluser]Unknown[/eluser]
Thanks i will try, but i have other question, i need validate that form, so, but i can't call any controller from the view, i need write the logic in the view? something how this:

Code:
$this->load->helper(array('form','url'));
   $this->load->library('validation');
   if($this->validation->run()==FALSE)
   {
    return $this->load->view('usuario/iniciar',"",true);
   }else{
    return $this->load->view('formsuccess',"",true);
   }
#4

[eluser]Glazz[/eluser]
That goes in your controller.

Views are just to show your web page content.




Theme © iAndrew 2016 - Forum software by © MyBB