Kohana 3 - Blog like route "/ post / YYYY / MM / DD / search engine-optimized-url"

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

Any idea how this works?

Thanks in advance!

+2


a source to share


1 answer


You need 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 (Controller_Post in this example), you put this method:

public function action_index($year, $month, $day, $title){
       //Your code here
}

      

+4


a source







All Articles