Welcome Guest, Not a member yet? Register   Sign In
Dynamic Header That Needs A Different HTML Structure
#1

[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>&lt;?php echo $username; ?&gt;</strong>! You are logged in now. &lt;?php echo anchor('/auth/logout/', 'Logout'); ?&gt;

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.


Messages In This Thread
Dynamic Header That Needs A Different HTML Structure - by El Forum - 02-17-2011, 08:37 AM
Dynamic Header That Needs A Different HTML Structure - by El Forum - 02-17-2011, 10:16 AM
Dynamic Header That Needs A Different HTML Structure - by El Forum - 02-17-2011, 11:02 AM
Dynamic Header That Needs A Different HTML Structure - by El Forum - 02-17-2011, 11:10 AM
Dynamic Header That Needs A Different HTML Structure - by El Forum - 02-18-2011, 02:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB