I have a controller in codeigniter called ‘Main’ with this function:
public function index ($id = false, $filter ='htmlentities') {
...
...
}
I want to call it through the URI ‘jumping’ the first parameter so that it remains ‘false’:
I would like to be able through the URI using something like:
'main/index/false/myfilter'
However this doesn’t work, does anyone know how can I ‘jump’ this first parameter so that its value remains being false but i am able to change the filter?
(changing parameter order in function is NOT an option)
Just test for the string
'false'at the top of the controller method:Another possibility might be to use a custom route and simply discard the first parameter. In your
app/config/routes.phpfile, add the rule:Now, when you visit ‘main/index/myfilter’, the
$idparameter will be set tofalse(a string, not a boolean!)