Accessing classes - 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: Accessing classes (/showthread.php?tid=13804) Pages:
1
2
|
Accessing classes - El Forum - 12-06-2008 [eluser]garrettheel[/eluser] The template library just allows for smarty-like php variables and statements in the views, does it not? I wasn't aware that the template library allowed for a way to include a global header and footer as default on all pages? Accessing classes - El Forum - 12-06-2008 [eluser]dpgtfc[/eluser] [quote author="garrettheel" date="1228628131"]The template library just allows for smarty-like php variables and statements in the views, does it not? I wasn't aware that the template library allowed for a way to include a global header and footer as default on all pages?[/quote] Maybe I am misunderstanding. When you say "header" and "footer" You mean the old school: include "header.inc"; right? If you have a template, why do you need a header and footer? You do this in the controller: Code: function index() With a template system you don't need a header and a footer. Accessing classes - El Forum - 12-06-2008 [eluser]garrettheel[/eluser] Maybe that is what I'm looking for.. If it's not too much trouble, could you give me a basic example of the index function with the header and footer included? (assuming they're both simply views) Accessing classes - El Forum - 12-06-2008 [eluser]dpgtfc[/eluser] [quote author="garrettheel" date="1228628558"]Maybe that is what I'm looking for.. If it's not too much trouble, could you give me a basic example of the index function with the header and footer included? (assuming they're both simply views)[/quote] With a template the header and footer don't need to be in seperate views. You would have one single php file like so: Code: <html> I mean you could, but there would be no benefit from it, as you can make any part of the single template entirely dynamic based on the controller. Accessing classes - El Forum - 12-06-2008 [eluser]garrettheel[/eluser] So I get the templating system deal, but how are the variables $content and such passed to the view? Don't I need to explicitly state this somewhere? Accessing classes - El Forum - 12-07-2008 [eluser]garrettheel[/eluser] Shameless bump.. Accessing classes - El Forum - 12-08-2008 [eluser]Pascal Kriete[/eluser] Quote:So basically what I’m trying to make is a page handler that is called at the end of a function when I want to display a page instead of $this->load->view(‘blah’); Lots of ways to do this. You can nest views, so you could create a template view: Code: <html> And then all you would need to do is define a content variable that references another view: Code: $data['title'] = 'My great Title'; The data variables are automagically available to all nested views. You could take it a step further and create a library that does that logic for you, So it might have a function like this: Code: function render($content, $data) Hope I understood the question correctly . |