Application Constants (header, footer) |
[eluser]x_dde_x[/eluser]
Still trying to figure Codeigniter out... In my previous sites, I've always constructed around not re-writing header and footer information on each view. For example, I would render the page thusly from the index call: Code: include('header'); And all meta data and css links would be appended, and the page would be constructed. Does CodeIgniter have a similar mechanism, or do you have to load other views in each individual view file?
[eluser]Rey Philip Regis[/eluser]
Yup Ive discussed that before try to visit this link: I think you and khuram have the same problem..There I discussed a technique that you can use without having to include you header and footer on every view. You just need a template. What I do there is loading a view within a view. You'll start on creating a master template and in that template you need to load your header and footer just once and the content will allso be loaded but its loaded dynamically by setting them in your controller. This is what we call Two step view pattern, I think haha.. Try to view this: http://ellislab.com/forums/viewthread/96974/ Hope this helps..
[eluser]got 2 doodle[/eluser]
I started to work in a very modular way. In controller define all the data .. building an array called 'data' Code: ..in a function .. define your views note that we are setting $output as the view content and then appending to this var. note the parameter 'true' this keeps appending and also note that you only have to send your data array in the when you first define the output. Code: /* Load views */ note I grouped view chunks together as in Code: function header_view ($data) Code: function footer_view ($output) Code: $this->output->set_output($output); anyway, I doubt anyone else works exactly like me but for the project this approach worked. adamp had a nice approach with backendpro, a page class and an asset management class To get the views looking how I want, I start my layout work in Dreamweaver and then take it all apart in logical chunks. doodle
[eluser]x_dde_x[/eluser]
[quote author="Rey Philip Regis" date="1228261910"]Yup Ive discussed that before try to visit this link: I think you and khuram have the same problem..There I discussed a technique that you can use without having to include you header and footer on every view. You just need a template. What I do there is loading a view within a view. You'll start on creating a master template and in that template you need to load your header and footer just once and the content will allso be loaded but its loaded dynamically by setting them in your controller. This is what we call Two step view pattern, I think haha.. Try to view this: http://ellislab.com/forums/viewthread/96974/ Hope this helps..[/quote] Awesome, this helped quite a bit. I built the template page and am off to the races!
[eluser]Michael Wales[/eluser]
I like to just do something simple like this: controllers/posts.php Code: function index() { views/layout.php Code: $this->load->view('_header'); If my headers/footers/sidebars etc. are going to contain dynamically generated content, I usually use Zacharias' awesome Wick library.
|
Welcome Guest, Not a member yet? Register Sign In |