Page layout system - 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: Page layout system (/showthread.php?tid=8364) |
Page layout system - El Forum - 05-15-2008 [eluser]jbads[/eluser] Hi, I've been wondering how other people deal with the layout of their pages. Here is an example of how I've been doing it. Code: function register(){ now if someone loads this page and fills in form the form action goes to the registration processing function, now if there is an error with the data they submitted, ie required fields aren't filled in, it redirects to /register page again but post data is obviously cleared and the user must start the form again. You see my problem? So how do the rest of you deal with page layout / templates etc.?? Page layout system - El Forum - 05-15-2008 [eluser]mrtopher[/eluser] I tend to use more of a layout approach. So instead of having three or four templates which I load in and around my content line by line, I have a layouts folder in the views folder which has the overall look and feel and I simply load individual views in those layouts. For example: Code: $page_data = array( In regards to your validation question, I don't redirect the users. I simply make a call to the form display function from within the process function. For example: Code: function display_form() Hope this helps! Page layout system - El Forum - 05-18-2008 [eluser]jbads[/eluser] Hey thanks for reply. In the example given, what code would be in the display function? Page layout system - El Forum - 05-18-2008 [eluser]JoostV[/eluser] I always load a main template and include other templates that I might need from that template. For instance: Controller: Code: // Put stuff in data array to send to view View: Code: <?php require_once 'page_head.php'; ?> Since the subview files are included in the main view file tehy also have acces to any data in $this->data. Page layout system - El Forum - 05-18-2008 [eluser]louis w[/eluser] I built a custom library which wraps a view. The wrapper contains the header, footer and common includes. Then I call the library either with a view (which then gets called by the wrapper) or give it a data strng which gets included in the wrapper. It's quite handy. |