开发者

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

开发者 https://www.devze.com 2022-12-29 03:38 出处:网络
I\'m trying to create the above mentioned route... year, month, day and title should be passed to the method.

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 i开发者_Python百科n advance!


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
}
0

精彩评论

暂无评论...
验证码 换一张
取 消