Welcome Guest, Not a member yet? Register   Sign In
What do you guys do with pages that don't require a controller?
#1

[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?
#2

[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.
#3

[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
 
#4

[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!
#5

[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
#6

[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.
#7

[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.




Theme © iAndrew 2016 - Forum software by © MyBB