How do you implement master templates that are used across the site? |
[eluser]KeyStroke[/eluser]
Hi, I'm basically trying to have a master template that I could always output content to (preferably automatically without a call) across the site. I know some will suggest outputting every page section in its own $this->load->view() call in every method, but that's an incredibly ugly solution. There's another way which consists of playing around with hooks to automatically output the master template, but it's a bit hackish in my opinion. I've also found the Template library (http://www.williamsconcepts.com/ci/codei...index.html), which is so far my best option, but it's a bit complex and I'd rather use something simpler. So, my question is, what do/would you use in such case where you need a master template? Appreciate your help
[eluser]Mischievous[/eluser]
I'm currently using a modified version of the Template Library you listed that i've modified to work with modular separation and it works amazingly! Its really really not complex at all! Simply call Code: $this->template->write_view('content', 'view_file'); then first parameter is a the region you specify in the template_config file? and the second parameter is the view file to load into the region? the config_file is a simple array?
[eluser]KeyStroke[/eluser]
is this basically the modification? or is there more to it?
[eluser]Tominator[/eluser]
If you use COMPER Template Parser (http://ellislab.com/forums/viewthread/153269/), It's so simple: PHP: Code: $this->load->library('parser'); TPL: Code: <html> OR you can use "INCLUDE" in every template (yes it's not longer master template): PHP: Code: $this->load->library('parser'); TPL: Code: <!-- INCLUDE overall_header.tpl -->
[eluser]Karlos23[/eluser]
Well I have a public var in my controller $data and each new controller contains it. It has a title, menu and content part to it what allows me to leave the template and just create other views leaving the master template alone. Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?> |
Welcome Guest, Not a member yet? Register Sign In |