2010-05-06 123 views

回答

4

你必須創建在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', 
)); 

那麼你的控制器內(在這個例子中,Controller_Post),你把這個方法:

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

你應該在更嚴格你的正則表達式。參數也可以通過「this-> request-> param('year')」來訪問。 – 2010-05-06 13:34:22

+0

你的意思是說,限制月份爲'[0-3] [0-9]'? – dusan 2010-05-06 14:05:45

+0

精湛,你很棒。感謝您的不斷幫助! :) – n00b 2010-05-06 15:17:22