Do not parse any named parameters:
Router::connectNamed(false);
Parse only default parameters used for CakePHP's pagination:
Router::connectNamed(false, array('default' => true));
Parse only the page parameter if its value is a number:
Router::connectNamed(array('page' => '[\d]+'), array('default' => false, 'greedy' => false));
Parse only the page parameter no matter what.
Router::connectNamed(array('page'), array('default' => false, 'greedy' => false));
Parse only the page parameter if the current action is 'index'.
Router::connectNamed(
array('page' => array('action' => 'index')),
array('default' => false, 'greedy' => false)
);
Parse only the page parameter if the current action is 'index' and the controller is 'pages'.
Router::connectNamed(
array('page' => array('action' => 'index', 'controller' => 'pages')),
array('default' => false, 'greedy' => false)
);
### Options
- greedy Setting this to true will make Router parse all named params. Setting it to false will
parse only the connected named params.
- default Set this to true to merge in the default set of named parameters.
- reset Set to true to clear existing rules and start fresh.
- separator Change the string used to separate the key & value in a named parameter. Defaults to :
public static connectNamed ( array $named, array $options = [] ) : array | ||
$named | array | A list of named parameters. Key value pairs are accepted where values are either regex strings to match, or arrays as seen above. |
$options | array | Allows to control all settings: separator, greedy, reset, default |
return | array |