CodeIgniter Forums
uri routing question - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: uri routing question (/thread-2556.html)

uri routing question - El Forum - 08-12-2007

I would like to find a way to have 1 controller named "friends".

then be able to do this:

But people will be signing up so I can't just

do this by hard coding it in the routes.php file.

The only other solution I could think of is to have a script that creates another controller each time a new person is added and it extends the base class.

Is there some way I could use a hook to access the datatbase before the routes file is accessed and then have it read a dynamic list of routes or something like that?

I just don't want to use:

as it defeats the whole design of what I am trying to create.

uri routing question - El Forum - 08-12-2007

[eluser]Michael Wales[/eluser]
Yes, it can be done with routing.

URI routing is completed from top-down, so setup the routes for all of your hard-coded stuff (user/login, user/register, etc). Then setup a route for :any and direct it to whatever controller/method you want - something like friends/view would work. Use uri->segment(1) to determine if it's someone's username and process.

BTW: Remember not to let people register with the username of your controllers - otherwise they'll never be able to see their profiles.

uri routing question - El Forum - 08-12-2007

Thanks for the help.

uri routing question - El Forum - 08-12-2007

I figured it out. but it doesn't seem to work when you want to call a function. works

but if I have a function called age() in the controller and I go to

All I get is it calling the index()

and i set up a route to in an attempt to fix it with

$route[':any/age'] = "test/age";

but that did not help either.

Any ideas?

K I wish we could delete our posts when we solve them ourselves, lol.

I figured out its all about the order in which you list the routes, which is what you were talking about earlier.

uri routing question - El Forum - 10-23-2007

i wait for answer too, somebody help ??