2013-05-25 2 views
0

내가 뭘 잘못했는지 알지 못합니다. 나는 두 개의 명명 젠드 경로를 가지고 :Zend routes 두 경로에 같은 수의 매개 변수가 필요합니다.

$route = new Zend_Controller_Router_Route(
        'catalog/:categoryIdent/:productIdent/', 
        array(
         'action' => 'viewproduct', 
         'controller' => 'catalog', 
         'module' => 'eshop', 
         'categoryIdent' => '', 
         'productIdent' => ''       

        ), 
        array(
         'categoryIdent' => '[a-zA-Z-_0-9]+', 
         'productIdent' => '[a-zA-Z-_0-9]+' 
        ) 
    ); 
    $router->addRoute('catalog_category_product', $route); 

    // catalog category route 
    $route = new Zend_Controller_Router_Route(
        'catalog/:categoryIdent/:page/', 
        array(
         'action' => 'viewcategory', 
         'controller' => 'category', 
         'module' => 'eshop', 
         'categoryIdent' => '', 
         'page' => '' 

        ), 
        array(
         'categoryIdent' => '[a-zA-Z-_0-9]+' 
        ) 
    ); 

    $router->addRoute('catalog_category', $route); 

나는 그것의 모든 미세 catalog_category 호출하지만 두 번째 경로에서 viewcategory 조치를 사용 catalog_category_product 위해 전화 할 때. 그것의 문제를 의미합니다 : url의 page 변수, resp. URL에서 동일한 인수 개수? 페이지 번호없이 카탈로그/카테고리 1/제품 1 (- 카탈로그/카테고리 1 제품/1

-

범주의

: - 예를 들어, 나는 itsn't가 nessesary 나는 두 개의 서로 다른 그러나 유사한 경로를 좀하고 싶습니다 생각)

나는/카탈로그 경로 catalog_category_product의 형태를 변경할 때 : categoryIdent/뭔가/: productIdent는/그래서 그 여기

이 경로가

$this->url(array('categoryIdent' => categoryIdent, 'productIdent' => productIdent), 'catalog_category_product', true); 

$this->url(array('categoryIdent' => 'cerveny-cedr', 'page' => 'pageNumber'), 'catalog_category', true); 
를 호출되어 작업

도움을 주셔서 감사합니다

답변

1

경로가 역순으로 검사되므로 ZF 라우터는 URL이 일치 할 때 catalog_category_product 경로 앞에 catalog_category 경로를 확인합니다. 인수의 수는 문제가되지 않지만 'page'매개 변수에 제한을 두지 않았으므로 일반적으로 catalog_category_product URL과 일치하는 모든 URL은 catalog_category과 일치합니다.

'페이지'는 숫자 여야하므로 두 번째 경로에 해당 제한을 추가하면 문제가 해결됩니다.

+0

당신은 맞습니다. 저는 Zend 라우트의 어셈블리를 바꾸는 것을 염두에 두었습니다. 그러나 나는 Zend가 url (: page vs : productIndent)에 주어진 변수 이름과 다른 것을 인식한다고 생각했습니다. 'page'=> '\ d +'문제가 해결되었습니다. 그 바보 같은 실수, 정말 고마워. – DoZzOR