Welcome Guest, Not a member yet? Register   Sign In
URI segments, use custom routing?
#1

[eluser]msteudel[/eluser]
I'm used to name value pair uris ,e.g.

Code:
classroom.php?action=create&userId=9

Now my thought with CI would be to do something like:

Code:
admin/classroom/create/user_id/9
(admin is a sub-folder)

But of course CI would break it up like:
Code:
controller=classroom
method name=create
arg1=user_id
arg2=9

My method only needs one arg
Code:
function create( $userId ) {
    //do stuff
}

So would you just construct your url like:

Code:
admin/classroom/create/9

Or is there a way to map it so that the uri stays descriptive:

I tried something like this:
Code:
$route['classroom/create/user_id/(:num)'] = 'admin/classroom/create/$1';
$route['classroom/create/user_id/:any'] = 'admin/classroom/create/$1';

These custom routes didn't seem to work.

Is this the right way to go about this?

TIA


Messages In This Thread
URI segments, use custom routing? - by El Forum - 04-30-2010, 05:44 PM
URI segments, use custom routing? - by El Forum - 04-30-2010, 05:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB