Welcome Guest, Not a member yet? Register   Sign In
design question, 2 column site
#1

[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?
#2

[eluser]InsiteFX[/eluser]
Create a MY_Controller then you can put all your code
in it, then extend MY_Controller to your new Controllers.

Enjoy
InsiteFX
#3

[eluser]newtonianb[/eluser]
perfect! thanks so much




Theme © iAndrew 2016 - Forum software by © MyBB