2017-10-20 2 views
1

내가 my-website.com/app/##해야 내가 생성하기 위해 애 쓰고 url view helper in Zend Framework 2젠드 프레임 워크이 점점 경로에서 URL

의 URL을 사용하여 URL을 생성한다 할 노력하고있어 (##은 "ownerID")이 같은 뷰 헬퍼 사용하여이를 생성 할 때

은 어떻게됩니까 같다 여기서,

$this->url('mymodule', array('action'=>'show', 'ownerID'=>'28')); 

는 단지 "my-website.com/app"를 생성입니다 만 나는 "my-website.com/app/28"을 라우팅 설정에 기반하여 기대하고있다. 여기

리디렉션> $ this-를 사용할 때 같은 문제가 발생 내 module.config.php 파일

'router' => array(
'routes' => array(
    'mymodule' => array(
     'type' => 'segment', 
     'options' => array(
      'route' => '/app', 
      'defaults' => array(
       'controller' => 'MyModule\Controller\MyModule', 
       'action'  => 'show', 
      ), 
     ), 
     // Defines that "/app" can be matched on its own without a child route being matched 
     'may_terminate' => true, 
     'child_routes' => array(
      'archive' => array(
       'type' => 'segment', 
       'options' => array(
        'route' => '/:action[/:ownerID[/:clientID]]', 
        'defaults' => array(
        ), 
        'constraints' => array(
         'action' => '[a-zA-Z][a-zA-Z0-9_-]*', 
         'ownerID'  => '[0-9]+',        
         'clientID'  => '[0-9]+', 
        ) 
       ), 
      ), 
      'single' => array(
       'type' => 'segment', 
       'options' => array(
        'route' => '/:ownerID[/:clientID]', 
        'defaults' => array(
         'action'  => 'show', 
        ), 
        'constraints' => array(
         'ownerID'  => '[0-9]+', 
         'clientID'  => '[0-9]+', 
        ) 
       ), 
      ), 
     ) 
    ), 
) 
), 

에서 경로 정보입니다() -> toRoute.

수동으로 입력 할 때 모든 경로가 예상대로 작동합니다. 그저 나를 괴롭히는 URL 생성 일뿐입니다.

답변

0

질문에 더 직접 답하기 위해 최상위 경로 이름 ("mymodule") 만 URL 도우미로 전달하기 때문에 기대 한대로 작동하지 않습니다. ownerID는 하위 라우트의 일부입니다.

당신이 실제로 원하는 것은 :

$this->url('mymodule/archive', array('action'=>'show', 'ownerID'=>'28')); 

(또는 가능 mymodule/single 원하는 출력에 따라 다름).

관련 문제