Welcome Guest, Not a member yet? Register   Sign In
User routing
#1

[eluser]Nial[/eluser]
I have the following route rule:
Code:
$route['user/:any'] = "user/view";

Which makes domain.com/user/username possible.

However, I'd like to be able to do: domain.com/user/username/rss, for example. Where rss is a method within the user controller (just as view is).

How can I accomplish this?
#2

[eluser]m4rw3r[/eluser]
add:
$route['user/:any/rss'] = 'user/rss';
above the user/:any rule, I think
#3

[eluser]marcoss[/eluser]
In the first place, and from an design perspective, it would be better to use domain.com/rss/username instead, otherwise, when your app grows, routing will get really complex, you will have to deal with domain.com/user/username/photos, domain.com/user/username/notes, domain.com/user/username/blog, all in the same controller, instead of photos/username, notes/username, blogs/username.

Anyway, if you still want to go with that design, you should avoid the routes option and use the _remap() function inside your controller, there you can intercept the request before the default method gets called and route it based on the username and "action" requested.




Theme © iAndrew 2016 - Forum software by © MyBB