내가

2011-12-24 3 views
1

내가 경로에 대한 bootstap.php 코드의 줄 다음 한 kohana 프레임 워크에서 함수에 전달할 매개 변수를이 방법내가

Route::set('ads','ad/<ad>(/<affiliate>)') 
->defaults(array(
    'controller' => 'ads', 
    'action'  => 'index', 
)); 

그럼 내가 그 function.Url에 매개 변수를 전달했습니다 어떻게 로컬 호스트/index.php/ads /는 작동하지만 localhost/index.php/ads/12를 제공 할 때 404 오류를 표시합니다. ads.php에서 이러한 값에 액세스하는 방법을 알고 있지만 url에서 매개 변수를 전달하는 방법은 알고 있습니다. .

+0

는 [이 게시물]을 참고하시기 바랍니다 (http://stackoverflow.com/faq#signatures) – Dan

답변

0

무엇을 당신의 오타 (ads하지 ad)가 아닌 경우

Route::set('ads','ad/<ad>(/<affiliate>)', array('affiliate' => '.*')) 
->defaults(array(
    'controller' => 'ads', 
    'action'  => 'index', 
)); 
+1

는, 그렇지 않으면 그 값을 선택적 매개 변수 읽기 디폴트는 null –

1

확실하지에 대한하지만,이 경로로 :

Route::set('ads','ads/<ad>(/<affiliate>)') 
->defaults(array(
    'controller' => 'ads', 
    'action'  => 'index', 
)); 

로컬 호스트/index.php를/광고/(12)에있다 작업. 컨트롤러에서 당신에 의해 매개 변수에 액세스 할 수 있습니다 : 다음 통과하면

$this->request->param('ad');