Welcome Guest, Not a member yet? Register   Sign In
newbie MVC question - where should header footer code go?
#11

[eluser]no-cost lab[/eluser]
Thanks George!
#12

[eluser]Brayan[/eluser]
Hey Bill the Grue.

You can do it like I do:

create a view called template.php, and put this into:

Code:
<!DOCTYPE html>
&lt;html lang="en"&gt;
&lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
    &lt;title&gt;&lt;?php echo $title; ?&gt;&lt;/title&gt;
    &lt;link rel="stylesheet" href="&lt;?php echo base_url();?&gt;assets/css/style.css" type="text/css" media="screen" /&gt;
&lt;/head&gt;
&lt;body&gt;
    <div id="wrapper">      

        <div id="header">
            <h1>&lt;?php echo $title; ?&gt;</h1> &lt;!-- or create a view and load here --&gt;
        </div>

        <div id="main_content">
            &lt;?php $this->load->view('menu'); ?&gt;
            &lt;?php $this->load->view($page); ?&gt;

        </div>

        <div id="footer">
            Copyright 2010. &lt;!-- or create a view and load here --&gt;
        </div>
            
    </div>
&lt;/body&gt;
&lt;/html&gt;

and in a controller, here is a method example:
Code:
class myclass extends Controller{
    private $data;
    function index() {        
            $this->data['title'] = 'Welcome back !';
            $this->data['page'] = 'welcome_message';
            $this->load->view('template', $this->dados);        
    }
}

Big Grin




Theme © iAndrew 2016 - Forum software by © MyBB