开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜