mysite/username - How to? |
[eluser]Jônatan fróes[/eluser]
The title says everythig... Can someone helpe me?
[eluser]Colin Williams[/eluser]
Quote:The title says everythig… And yet, it says nothing at all. You have two options. 1.) Have a procedure that writes/modifies your config/routes.php file so you can manage routes from the application and not just your text editor. 2.) Extend/override CI_Router class, specifically the _set_routing() method.
[eluser]Jônatan fróes[/eluser]
I wanna use the routing... I Already have a controller like Class User Extends Controller { function show_user($post_id) { .... } }
[eluser]Alex.[/eluser]
1) Make a route for every controller on your site. E.G. $route['register:any'] = 'register$1'; 2) After defining a route for every controller, define another one like so $route['(.+)'] = 'users/viex/$1'; If I remember my regex correctly, then that will call the users controller when a 'username' is encountered.
[eluser]Colin Williams[/eluser]
"Catch-all" routing like that, Alex, is really a less-robust method of implementing things like this. I know it's something everyone cooks up at first, but I think for more robust solutions, extending the modifying CI_Router is the way to go.
[eluser]Référencement Google[/eluser]
Check that post, it's similar to your question: http://ellislab.com/forums/viewthread/85290/
[eluser]Alex.[/eluser]
[quote author="Colin Williams" date="1217314256"]"Catch-all" routing like that, Alex, is really a less-robust method of implementing things like this. I know it's something everyone cooks up at first, but I think for more robust solutions, extending the modifying CI_Router is the way to go.[/quote] I know it's not the most graceful solution, but it's the easiest way to get the desired effect.
[eluser]Référencement Google[/eluser]
I don't find anything difficult in extending the router class. Post edit (clarification of my answer) Alex, your method work, however, I am still thinking it is more easy to do it by extending the router class rather than your method. I also in my answer tried to push people to use good practices, that's why I said "I don't find anything difficult".
|
Welcome Guest, Not a member yet? Register Sign In |