![]() |
Multiple templates, loading default variables for main template? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Multiple templates, loading default variables for main template? (/showthread.php?tid=3801) |
Multiple templates, loading default variables for main template? - El Forum - 10-22-2007 [eluser]fancms[/eluser] Currently I have it set up like so: - template is the main template that wraps around the content. it contains a variable to echo the content passed by the controller - in the controller I have it set up so that $data = all the template variables I need to load for that controller Code: $template['content'] = $this->parser->parse('controllertemplatename', $data, true); #calls the parser - finally, the call to output the whole page: Code: $this->parser->parse('maintemplatename', $template); My problem is that the main template has tags (ie {lang_something}), and those tags are of course not going to get output properly because the $template variable doesn't hold the array for it. I could copy/paste the array with the needed variables but then I'd need to do it for every controller which would make upgrading that menu a nightmare. Do I need to create a controller for the main template? Is there a way to load the array of variables without copy/pasting it over and over? Am I overlooking something completely obvious? (Wouldn't be the first time ![]() Multiple templates, loading default variables for main template? - El Forum - 10-22-2007 [eluser]Jatinder Thind[/eluser] I use views to accomplish something similar to what you want to do. Take a look at the code below: Code: //This data will be passed to controllertemplatename view This should be pretty self explanatory. Let me know if you need detailed explanation. Multiple templates, loading default variables for main template? - El Forum - 03-07-2010 [eluser]Unknown[/eluser] Hi Jatinder...i was working like you with your '$inner method'...i was read it before in other post and it works well...but, imagine that you have this Code: $data_principal['base']=$this->config->item('base_url'); //just some paths in my config how i can send the content of $data_principal to 'content' view and 'index' view at the same time with a single array?? thanks a lot Multiple templates, loading default variables for main template? - El Forum - 03-08-2010 [eluser]InsiteFX[/eluser] You can also do it like this: Code: function index() Enjoy InsiteFX |