Welcome Guest, Not a member yet? Register   Sign In
Another Dynamic routes.php discussion
#1

[eluser]kmanlove[/eluser]
I've been using Codeigniter for a while, but this is my first time posting a question. I've looked through the forums for two days, but I wanted to put this out there again to get some better opinions. Please forgive me and pass me in the right direction if this discussion has already happened. I haven't seen anything that is this thorough.

I'm creating a CMS that allows users to create their own pages. I would like to make a dynamic routes.php file, so the pages they create have more standard URIs. I've found plenty of solutions that fall into two camps: a) open a database connection in routes.php, read in the 5 or 6 URIs every time, or b) when the database URIs are updated, write to a file that is included in routes.php. Now, I've seen it done with hooks, extending and overriding classes, etc. No matter how it's done, there are a few concerns I have about each method.

Database: the database is being used (though lightly) at each call to the router, which seems like it might slow things down. The router experiments I've done already seem pretty slow. Also, people have discounted this method because of two database connections. Clearly, I will close the first connection. What kind of problem would this actually cause?

File: The biggest problem with this is making a folder writable. I'm not terribly interested in making my config folder writable. Please let me know if this fear is unfounded. Also, it seems that writing to a file isn't as safe as a standard old database connection. Again, this could completely be unfounded again, but that's why I'm asking.

So, please... weigh in. Let me know what you all think. I'm open to any discussion besides one about why I shouldn't be rerouting in the first place. ;-) Thanks in advance for your thoughts.

Keith
#2

[eluser]Dam1an[/eluser]
I also have a CMS as part of my current application, and am using the modifed router librray by e-mike in this post

What it does, is any request which doesn't match an existing controller will get passed to a fallback contoller. In there, you can get the content which matches that slug and embed it in your template.
#3

[eluser]kmanlove[/eluser]
Thanks a lot. That was really an elegant, perfect solution. Took very little tinkering and is easily updatable. I saw that in the forums but saw it as a different application. Thanks again.




Theme © iAndrew 2016 - Forum software by © MyBB