CodeIgniter Forums
URI segments, use custom routing? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: URI segments, use custom routing? (/thread-30050.html)



URI segments, use custom routing? - El Forum - 04-30-2010

[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


URI segments, use custom routing? - El Forum - 04-30-2010

[eluser]msteudel[/eluser]
Actually nevermind I forgot to add in admin at the beginning of the route.