php - Router_Route with optional parameters -
i have following route:
$gridroute = new zend_controller_router_route( ':module/:controller/list/:order/:dir/:page', array ( 'module' => 'default', 'controller' => 'index', 'order' => '', 'dir' => 'asc', 'page' => 1, 'action' => 'list' ), array ( 'page' => '\d+' ) ); $router->addroute('grid', $mainroute->chain($gridroute));
i able add optional parameter 'filter' route. use following url:
http://example.org/default/list/filter/all/lname/asc/1 or http://example.org/default/list/lname/asc/ or http://example.org/default/list/filter/all
either 1 should work. tried place optional parameter in route did not work. ideas?
typically, in zend's router, in php, optional parameter parameter has default value. add 1 filter
parameter:
$gridroute = new zend_controller_router_route( ':module/:controller/list/:order/:dir/:page/:filter', array ( 'module' => 'default', 'controller' => 'index', 'order' => '', 'dir' => 'asc', 'page' => 1, 'action' => 'list', 'filter' => null, // define default filter here ), array ( 'page' => '\d+' ) );
Comments
Post a Comment