Rewrite url vs Controller |
[eluser]stingray9[/eluser]
Hi, i got a little question, let me explain my problem. I made it possible for a costumer on my application to create three pages. They can give the page a title and content. Every page is saved in the database under page1, page2 and page3. Now, my controller is extra, with functions: page1, page2 and page3. So the url they see is basic_url/extra/page1 But it would be more nice, if the url was the title they have set up their-self (saved in the database) and not that ugly extra/page1. The problem is referring to my correct controller by then. I hope i explained it well and someone have a possible solution for me.
[eluser]stingray9[/eluser]
[quote author="theprodigy" date="1306555012"]Take a look at CodeIgniter's routing[/quote] Thanks for answering. So you believe it's possible to write some php code in that route config file? As i don't know the titles, they are saved in the database.
[eluser]osci[/eluser]
You define only route there and then you can remap in your controller User Guide - Remap for example Code: public function _remap($method, $params = array()) but you should probably make page1, page2, page3 one function ie page since the serve the same purpose (display a title and a content) and the you would have Code: return call_user_func_array(array($this, 'page'), $params); btw the title should be translated to safe url (no spaces or disallowed characters), maybe saving it at db while updating record title so you can query against that.
[eluser]stingray9[/eluser]
Thanks mate, _remap() did the trick for me. Your post really helped me out!
|
Welcome Guest, Not a member yet? Register Sign In |