Welcome Guest, Not a member yet? Register   Sign In
Template-ish question--and how to use views?
#1

[eluser]K.Brown[/eluser]
I'm working on my first CI app--so bear with me. Smile

I'm setting up my page views like this:

Code:
<?php

class Event extends Application
{
    function Admin()
    {
        parent::Application();
    }
    
    function index()
    {
        $this->load->view('include/head');
        $this->load->view('include/home');
        $this->load->view('top');
        $this->load->view('featured');
        $this->load->view('eventslist');
        $this->load->view('footer');    
    }
    
    function other()
    {
        $this->load->view('include/head');
        $this->load->view('include/home');
        $this->load->view('top');
        $this->load->view('page');
        $this->load->view('footer');
    }

}

The action is happening in the top view right now:

Code:
<div id="topnav">
        &lt;?php
            if(logged_in())
            {?&gt;
            <p>Hey!</p>
            <ul>
                <li>&lt;?php echo anchor('logout', 'Logout'); ?&gt;</li>
                <li>&lt;?php echo anchor('create', 'Create'); ?&gt;</li>
            </ul>
        
        &lt;?php }
        else
        {?&gt;
            &lt;form method="POST" action="index.php/login" id="login"&gt;
            Username/Email:<br />
            &lt;input type="text" name="username" value="&lt;?php echo set_value('username'); ?&gt;" size="50" class="form" /&gt;&lt;?php echo form_error('username'); ?&gt;
            Password:<br />
            &lt;input type="password" name="password" value="&lt;?php echo set_value('password'); ?&gt;" size="50" class="form" /&gt;&lt;?php echo form_error('password'); ?&gt;
            &lt;input type="submit" value="Login" name="login" /&gt;
            &lt;/form&gt;
        &lt;?php } ?&gt;
        </div>

Sorry about my indenting...it may be hard to read.

I'm using this auth system.

So my question is: Is this a good way to go about this? I think not! Smile

I'd like to hear your input--I don't know any other way to do this, and I feel like it could be a little easier...perhaps I need to have a "logged_in" view and a "logged_out" view?




Theme © iAndrew 2016 - Forum software by © MyBB