CodeIgniter Forums
What do you guys do with pages that don't require a controller? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: What do you guys do with pages that don't require a controller? (/thread-25539.html)



What do you guys do with pages that don't require a controller? - El Forum - 12-15-2009

[eluser]mason22[/eluser]
What do you guys do with pages that don't require a controller? Do you just put it outside of the CI folders? Is that the right way of doing things? I always thought you needed to keep all of your files in the view folder... but this forces me to make a controller for pages that don't really need one. Do you guys just go ahead and make a controller so you can keep all of your files in one place?


What do you guys do with pages that don't require a controller? - El Forum - 12-15-2009

[eluser]kilishan[/eluser]
I do generally create a controller, which takes the page name and searches for it. Basically just a _remap() function and an index() function are all that is in that controller.

There is a library out there (that I haven't tried yet) called Site Migrate that may be what you're looking for.


What do you guys do with pages that don't require a controller? - El Forum - 12-16-2009

[eluser]John_Betong[/eluser]
[quote author="mason22" date="1260948599"]What do you guys do with pages that don't require a controller? Do you just put it outside of the CI folders? Is that the right way of doing things? I always thought you needed to keep all of your files in the view folder... but this forces me to make a controller for pages that don't really need one. Do you guys just go ahead and make a controller so you can keep all of your files in one place?[/quote]
 
What pages do you have that do not need a controller? What do you think is to be gained by circumventing a controller? I think this will create future problems by not using a controller because even though now your data may be static I am sure that this will change as your site progresses.

The MVC structure of the controller is that every page has to go through the controller before it is directed to a particular view.

The Welcome page is a good example that can be built upon to test your own pages. Once the MVC structure is in place it is very easy to add and many additional pages with or without having to pass data to pages "that do not need a controller". It is also easy to simply add tried and tested class plugins, models and libraries such as email, images, database, sessions, FTP, etc
 
 
edit: keyboard trouble
 


What do you guys do with pages that don't require a controller? - El Forum - 12-16-2009

[eluser]n0xie[/eluser]
[quote author="mason22" date="1260948599"]What do you guys do with pages that don't require a controller? [/quote]
I'm not sure what you mean by this. If you mean static pages that don't require any business logic, you could just use one generic 'static page' controller and return different static views from there, depending on some parameter or depending on the url structure.

Keep in mind that the controller does not equal 'the url'. You can map any controller to any url. You can map several url's to 1 controller. So you don't have to build a new controller for every page. Keep it DRY!


What do you guys do with pages that don't require a controller? - El Forum - 12-16-2009

[eluser]mason22[/eluser]
thanks guys. my url looked like this

mypgage.com/about.php

and I didn't want it to look like this

mypage.com/controller/about

then I remembered you could have an index function to make it look like this:

mypage.com/about


What do you guys do with pages that don't require a controller? - El Forum - 02-06-2010

[eluser]sophistry[/eluser]
sorry to be late to this thread - was just searching for mentions of site_migrate to see what people were doing with it...

one benefit of using site_migrate (which is not really a library, just a base controller) is that your url won't change at all from your "old-style" mypage.com/about.php.

sounds like you found a solution that works for you though. :-)

cheers.


What do you guys do with pages that don't require a controller? - El Forum - 02-06-2010

[eluser]mdcode[/eluser]
[quote author="n0xie" date="1260978447"][quote author="mason22" date="1260948599"]What do you guys do with pages that don't require a controller? [/quote]
I'm not sure what you mean by this. If you mean static pages that don't require any business logic, you could just use one generic 'static page' controller and return different static views from there, depending on some parameter or depending on the url structure.[/quote]
This is basically what I do... in general I have a "main", or "master" controller which apart from the main index or home page, I place other things such as the FAQ's page, or the credits page etc etc. Or as you put it, pages that don't necessarily require their own controller.