Here is an example to illustrate routing with parameters.
/config/routes.php
Router::connect(
'/:controller/:year/:month/:day',
array('action' => 'index', 'day' => null),
array(
'year' => '[12][0-9]{3}',
'month' => '(0[1-9]|1[012])',
'day' => '(0[1-9]|[12][0-9]|3[01])'
)
);
Parameters can be access like this:
/controllers/controller.php
function index(){
// params is stored in $this->params
$year = $this->params['year'];
$month = $this->params['month'];
$day = $this->params['day'];
//
}
No comments:
Post a Comment