[eluser]newtonianb[/eluser]
My website consists of two columns, the first column is the content of the page which is different for every controller, however the second column is a login/user account section which should be there for every controller which if not logged in will show a login box and if logged in will show user relevant data.
The way I currently have this setup is the following.
within my controller I have
$this->data['left_col'] = "views/mycurrent.php";
$this->logicForRightCol();
the above function does all the figuring out of is the user logged in, yes no, if not logged in then set
$this->data['right_col'] = "views/notloggedin.php";
else set to
$this->data['right_col'] = "views/loggedin.php";
it also handles the processing of the submit form when the user logs in...
I then do a
$this->load->view('template/flow', $this->data);
flow:
<?php $this->load->view('header'); ?>
<?php $this->load->view('body'); ?>
<?php $this->load->view('footer'); ?>
body:
contains all my body structure and has
$this->load->view($left_col); and $this->load->view($right_col); at appropriate sections
I am very happy with this setup except for code reuse: my question is: how can I structure this so that I don't have to copy paste the logicForRightCol function in every controller?