• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What's the practical way to load header and footer

#9
[eluser]JoostV[/eluser]
I use one master template from which I include header, footer, navbar, and so on.

I always seem to have one content template that has to be loaded dynamically. I set this in the controller, before I load the main template, like so:
Code:
$this->data['pagvars']['contentview'] = 'name_of_template';
$this->load->view('template_main', $this->data);

Now, in the template I load this specified template, if it exists:
Code:
if (isset($pagvars['contentview']) && file_exists($pagvars['contentview'] . '.php')) {
    // Contentview exists, so let's load it
    require_once($pagvars['contentview'] . '.php');
}
else {
    // Contentview is not set or does not exist
    show_error ('Problem loading contentview');
}


Messages In This Thread
What's the practical way to load header and footer - by El Forum - 06-08-2008, 09:04 PM
What's the practical way to load header and footer - by El Forum - 06-08-2008, 09:25 PM
What's the practical way to load header and footer - by El Forum - 06-08-2008, 09:47 PM
What's the practical way to load header and footer - by El Forum - 06-08-2008, 09:48 PM
What's the practical way to load header and footer - by El Forum - 06-08-2008, 10:13 PM
What's the practical way to load header and footer - by El Forum - 06-09-2008, 12:57 AM
What's the practical way to load header and footer - by El Forum - 06-09-2008, 01:08 AM
What's the practical way to load header and footer - by El Forum - 06-09-2008, 10:29 AM
What's the practical way to load header and footer - by El Forum - 06-09-2008, 12:16 PM
What's the practical way to load header and footer - by El Forum - 06-22-2008, 05:34 PM
What's the practical way to load header and footer - by El Forum - 06-22-2008, 05:53 PM
What's the practical way to load header and footer - by El Forum - 06-22-2008, 05:56 PM
What's the practical way to load header and footer - by El Forum - 06-23-2008, 09:29 AM
What's the practical way to load header and footer - by El Forum - 06-23-2008, 10:44 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.