CodeIgniter Forums
explicit controllers vs. class functions - 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: explicit controllers vs. class functions (/thread-5450.html)



explicit controllers vs. class functions - El Forum - 01-22-2008

[eluser]charlie spider[/eluser]
I'm working on a site with a CMS backend and it is my second CI project.

One of the things i would like to do with this is develop the ability to dynamically generate new pages. I'm currently storing all of the user editable content in a db and populating a couple of different view pages that act as templates. With the first site i developed in CI, i used a separate controller for every page of the site (small site - 8 pages).

I would like the url's for the new site to look like this:

www.some_site.com/whatever
www.some_site.com/some_content
www.some_site.com/more_content
www.some_site.com/yada_yada

BUT

i would like to be able to add a new page to the db and have the name of the page (shortened url-friendly version) to appear as if it were a controller class. In other words, be able to retrieve the controller class name from the db. Or at least make it look that way.

is there anyway to do this within the CI framework or am i looking at an .htaccess job ?

i have no problem adding dynamic pages that are created by a function but then the url's look like this:

www.some_site.com/controller/yada_yada

which is fine when the new page is appropriate for the structural hierarchy of the site. ie:

www.super_corporation.com/products/new_improved_fantasy

So i would like to know if controller classes ALWAYS have to be explicitly called or can they be faked using a function ?

i haven't had the time to delve far enough into CI to know if this is possbile to do using custom routes or hooks (don't know what either of those are even) but if someone could point me in the right direction i would be eternally gratefull.

Thanks in advance for any help


explicit controllers vs. class functions - El Forum - 01-22-2008

[eluser]ekeretex[/eluser]
Take a look at these screencasts.
The first one has what you need.


explicit controllers vs. class functions - El Forum - 01-22-2008

[eluser]dawnerd[/eluser]
Have you read anything about advances routing? It will sure help.

edit: guess not.

I would go read about it. Routes are very powerful.