Templating System - 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: Templating System (/showthread.php?tid=18749) |
Templating System - El Forum - 05-16-2009 [eluser]PHP Creative[/eluser] Hi there. I'm completely new to CodeIgniter. One thing I am struggling to understand is the templating system. Is it possible to have one 'index' file that includes the design (html + CSS) and then the content pages are included into it via the url eg urlhere.com/about/ would include the about page etc etc... Before using CodeIgniter on most sites I would use index.php?content=home, about, contact etc. Code: <html> Is there a similar approach you can use in CodeIgniter? Thanks a million Templating System - El Forum - 05-16-2009 [eluser]Jondolar[/eluser] The "typical" way is to load a header, then your content, then a footer. However, you can do what you are asking as well. If you are not familiar to MVC frameworks, you need to know that you will typically have a controller/function for your pages such as welcome/home, welcome/about, welcome/contact, etc. Each of these functions will load the header, load their content specific page and then load the footer. The documentation on views is pretty good to explain this. Templating System - El Forum - 05-17-2009 [eluser]Colin Williams[/eluser] You can either embed views or load them sequentially. It's up to you. See the Template library in my sig for an option that facilitates embedding views. Templating System - El Forum - 05-17-2009 [eluser]PHP Creative[/eluser] Thanks a million for that library. Is it possible to load separate views into the template using that library? I have tried loading the 'about' view into the template but it renders it before the template. Code: <?php Templating System - El Forum - 05-17-2009 [eluser]Colin Williams[/eluser] That is expected behavior because of how you coded it. I would suggest fully reading the CI docs first then Template's docs. |