How do u manage your views? |
[eluser]Christoph Rumpel[/eluser]
I am struggling these days with clearing my code and i am not sure how to manage my views. In my case i am working with a template view containing a headerview a contenview and a footerview. So everytime i load i view i just write: Code: $data['title'] = 'ShowTopics'; thx and greets Christoph
[eluser]stuckinphp[/eluser]
For matters of readability I'd start with using http://php.net/compact Code: $title = 'ShowTopics'; You are pretty stuck in the way that, if you want a view to load, you'll need to load it. If you can train yourself to use a naming convention like you have started to anyway ("_v") you could use a post controller hook (http://ellislab.com/codeigniter/user-gui...hooks.html) to find and load views automagically if they are available based on controller name. Although you'd need to do some ugly thing with public variables which likely defeats the point..
[eluser]John_Betong_002[/eluser]
Try searching this forum for "MY_Controller". This would allow you to include the common MY_Controller in all of your controllers. Also take a look at the third parameter for $this->load->view('template',$data, TRUE);
[eluser]mihaibaboi[/eluser]
You might want to take a look at "Template Library for CodeIgniter", by Colin Williams. You can find it here. I've been using it for some time now, and I find it very clean. |
Welcome Guest, Not a member yet? Register Sign In |