CodeIgniter Forums
CI beginner question - 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: CI beginner question (/showthread.php?tid=34554)



CI beginner question - El Forum - 10-03-2010

[eluser]Avril[/eluser]
Hello,

When creating a site with several pages it's simpler to create for example a header and a footer file and then include them into the other pages. This way you don't need to code every change on every page and we all win time.

But I've tried this with CI and it seems not to work for me, I'm referring to this thread that I've started load problem? .

So basically, I have a header.php (where I create my top navigation links) and I include it in for example index.php, the data seems not to load.
But if I load the navigation data in the homepage.php (controller where he pulls the blog posts from my db) then it works. I'm not sure what I'm doing wrong here?

Hope that I was clear enough, I can write bizar english sometimes Big Grin


CI beginner question - El Forum - 10-03-2010

[eluser]Bas Vermeulen[/eluser]
Hi Avril,

I load a template view from all my controllers and pass a main_view variable to it:

Code:
$data['main_view'] = 'login_form';
$this->load->view('template', $data);

The template view looks like:
Code:
// Load header
$this->load->view('header', $data);
// Load main view
$this->load->view($main_view, $data);
//Load footer
$this->load->view('footer', $data);


You could also use Phil's template library:
click


CI beginner question - El Forum - 10-03-2010

[eluser]Avril[/eluser]
Cool, it's working. Thanks!


CI beginner question - El Forum - 10-03-2010

[eluser]Bas Vermeulen[/eluser]
You're welcome Smile