CodeIgniter Forums
Template (kind off) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Template (kind off) (/showthread.php?tid=55894)



Template (kind off) - El Forum - 11-15-2012

[eluser]jurlan[/eluser]
Hi all,

I was wondering what's the best way to only load {header}, {menu} and {footer} only once throughout the application and just dynamically change the {content} according to the link being clicked?

Thanks in advance
/jurgen


Template (kind off) - El Forum - 11-15-2012

[eluser]noslen1[/eluser]
You should have a main router view named /views/index.php with a body like this :
Code:
<body>
    <header>
        <?php $this->view('include/header')?>
    </header>

    <aside>
        &lt;?php $this->view('include/menu')?&gt;
    </aside>

    <div id="main">
        &lt;?php $this->view($content); ?&gt;
    </div>

    <footer>
        &lt;?php $this->view('include/footer')?&gt;
    </footer>

&lt;/body&gt;

that you call in all of your controllers functions, and you dynamically pass your content template to load into the view :

Code:
$data->content = 'page/content';
$this->load->view('index', $data);



Template (kind off) - El Forum - 11-15-2012

[eluser]jurlan[/eluser]
Thanks a lot!
I've seen al kinds of solutions while googling, but this one definitely seems the best and easiest out there.
Thank you ;-)

/jurgen