Make route parameter optional in cakephp

196 Views Asked by At

I've created the following route in CakePHP:

Router::connect(
            '/design-idea-projects/:filtertype--:id',
            array('controller' => 'ourwork', 'action' => 'designideaprojects'),
            array(
                'pass' => array('filtertype', 'id'),
                'id' => '[0-9]+'
            )
        );

In this route I want to make the part /:filtertype--:id optional. How to do this? I'm not providing anything after /design-idea-projects/, it is showing missing controller error. I'm really not getting any idea.

Thanks.

1

There are 1 best solutions below

0
On

You can try this, hope it will work

Router::connect(
            '/design-idea-projects/*',
            array('controller' => 'ourwork', 'action' => 'designideaprojects'),
            array(
                'pass' => array('filtertype', '[0-9]+')
            )
        );