[eluser]piehouserat[/eluser]
I currently have something that looks like this
Code:
function index()
{
$header_data['page_title'] = 'Home';
$this->load->view('includes/header', $header_data);
if (!$this->tank_auth->is_logged_in()) {
$this->load->view('not_logged_in');
} else {
$data['user_id'] = $this->tank_auth->get_user_id();
$data['username'] = $this->tank_auth->get_username();
$this->load->view('logged_in', $data);
}
$footer_data['copy_year'] = date('Y');
$this->load->view('includes/footer', $footer_data);
}
not_logged_in view
Code:
Already a member? <?php echo anchor('/auth/login/', 'Login'); ?>
logged_in view
Code:
Hi, <strong><?php echo $username; ?></strong>! You are logged in now. <?php echo anchor('/auth/logout/', 'Logout'); ?>
What I want to do is move the logged in/out view into the header view. The only way I can think of doing this is to create two seperate header views - 1 for logged in users and 1 for those not logged in. This would mean that I would have 2 copies of the same header view with only a few small differences shown above between the two. This would increase code maintenance and doesn't seem like the most elegant solution.
I'm just starting out with CodeIgniter so perhaps I'm thinking about this the wrong way but there must be a way of having just one header view that can change html structure based on application logic.