Routing optional paremeter

How can I make a parameter optional in routing.

For example I have the following link
admin/admin_manage/index/(optional param}

into this
admin/manage/(optional param)

I'm doing the following:
$route['admin/manage/?(:any)'] = 'admin/admin_manage/$1';
but does not work


I'm using
$route['admin/manage/?(.*)'] = 'admin/admin_manage/index/$1';

and in my index function i have a parameter function index($sortby='id') which is optional, that will be used if nothing is there.

But with that routing code, it seem to delete the default param for function index.

Any ideas?

Thanks for any help!

I got it working and may not be the best way.

In my function where I receive the sort by, I check if the field exist and if it exist. If any of those are false, then I set to default.

[eluser]Miguel Diaz[/eluser]
Hi Jagar,

I have the same situation how do you do it.

Thanks in advance

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.