Welcome Guest, Not a member yet? Register   Sign In
Routing tricks

[quote author="Base Willy" date="1195403579"]Hi again!

This time we (I hope we, not just me, myself and I like it was last timeSmile) will talk about routing.

I have a controller named user and it has a function called profile. So we could se user's profile at /user/profile/user_login
What I want now is to do so that we could see that profile not only there but else at site.com/user_login.

I did it like this: (config/routes.php)
$route['((photos|blogs).+)'] = "$1";
$route['([a-zA-Z0-9_-]+)'] = "user/profile/$1";

We can't just route everything to user/profile because there are another controllers (photos and blogs in example) and that's what the first route for.

It seems to work fine but I wanted to discuss it and see if it's a good solution or there is a better way.

Viva la CI! :-)[/quote]

How do you link to that user's profile that way? Do you use:

<a href="http://site.com/user/profile/user_login">Profile</a>

or somehow do:

<a href="http://site.com/user_login">Profile</a>

Messages In This Thread
Routing tricks - by El Forum - 11-18-2007, 04:32 AM
Routing tricks - by El Forum - 12-12-2007, 02:48 PM
Routing tricks - by El Forum - 12-12-2007, 03:53 PM

Theme © iAndrew 2016 - Forum software by © MyBB