views:

321

answers:

1

Hi Guys,

I'm trying to create the above mentioned route... year, month, day and title should be passed to the method.

Any idea how that works?

Thanks in advance!

+3  A: 

You have to create an additional route in application/bootstrap.php:

Route::set('post', 'post/<year>/<month>/<day>/<title>', array('year'=>'\d{4}', 'month'=>'\d{2}', 'day'=>'\d{2}'))
    ->defaults(array(
            'controller' => 'post',
            'action'     => 'index',
));

Then inside your controller (in this example, Controller_Post), you put this method:

public function action_index($year, $month, $day, $title){
       //Your code here
}
dusan
You should be more restrictive in your regular expressions. The parameters can also be accessed via "this->request->param('year')" too.
The Pixel Developer
Do you mean, for example, restricting month to `[0-3][0-9]` ?
dusan
superb, you're great. thanks for your constant help! :)
n00b