Welcome Guest, Not a member yet? Register   Sign In
Routing optional paremeter
#1

[eluser]Jagar[/eluser]
How can I make a parameter optional in routing.

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

into this
Code:
admin/manage/(optional param)

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

Thanks
#2

[eluser]Jagar[/eluser]
I'm using
Code:
$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!
#3

[eluser]Jagar[/eluser]
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.
#4

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

I have the same situation how do you do it.

Thanks in advance




Theme © iAndrew 2016 - Forum software by © MyBB