2016-08-27 3 views
0

私のシステムには、同じコードスタイルを使用してモジュールを開発できるグローバルな動的ルートがあります。 URLのブレッドクラムを/checkout/list/cart-type/2のように生成したいのに、ナビゲーション設定が自分のURLと一致しない。ZF2がブレッドクラム用の動的ワイルドカードルートに一致しません

一方、私が単に/checkout/listにルーティングすると、正しく動作します。

設定を正しく設定してください。

私のルータの設定

'router' => [ 
    'routes' => [ 
     'default' => [ 
      'type' => 'Segment', 
      'options' => [ 
       'route' => '/[:controller[/[:action]]]', // global route 
       'constraints' => [ 
        'controller' => '[a-zA-Z]?[a-zA-Z0-9_-]*', 
        'action' => '[a-zA-Z]?[a-zA-Z0-9_-]*', 
       ], 
       'defaults' => [ 
        'controller' => 'index', 
        'action' => 'index', 
       ], 
      ], 
      'may_terminate' => true, 
      'child_routes' => [ 
       'wildcard' => [ 
        'type' => 'Wildcard', 
        'priority' => 10, 
        'options' => [], 
       ], 
      ], 
     ], 
    ], 
], 

マイナビ設定

'navigation' => [ 
    'default' => [ 
     'checkout' => [ 
      'module' => 'checkout', 
      'label' => 'Home', 
      'route' => 'default', 
      'controller' => 'index', 
      'action' => 'index', 
      'pages' => [ 
       'checkout-list' => [ 
        'label' => 'Invoices', 
        'route' => 'default/wildcard', 
        'controller' => 'checkout', 
        'action' => 'list', 
        'params' => [ 
         'cart-type' => 2 
        ], 
       ], 
      ], 
     ], 
    ], 
], 
+0

再定義「ID」の子セグメントルートにルート '/チェックアウト/リスト/カート型/ 2 '正しくルータによってハンドルでましたか? –

答えて

0

あなたがパラメータとしてcontrolleractionを定義したので、(テストしていない)してみてください。

'navigation' => [ 
    'default' => [ 
     'checkout' => [ 
      'module' => 'checkout', 
      'label' => 'Home', 
      'route' => 'default', 
      'controller' => 'index', 
      'action' => 'index', 
      'pages' => [ 
       'checkout-list' => [ 
        'label' => 'Invoices', 
        'route' => 'default/wildcard', 
        'params' => [ 
         'controller' => 'checkout', 
         'action' => 'list', 
         'cart-type' => 2 
        ], 
       ], 
      ], 
     ], 
    ], 
], 

または:

$url('default/wildcard', [ 
    'controller' => 'checkout', 
    'action' => 'list', 
    'cart-type' => 2 
]; 
+0

変更がない、パンくずリストが表示されない – serzhxaker

+0

'$ url( 'default/wildcard'、[...]);'を呼び出すとどうなりますか? –

+0

次の出力結果を得ました。 '' '/ checkout/list/cart-type/2''' – serzhxaker

0

私は解決策を見つけました。

問題は、ワイルドカードのルート

'default' => [ 
    'type' => 'Segment', 
    'options' => [ 
     'route' => '/[:controller[/[:action]]]', // global route 
     'constraints' => [ 
      'controller' => '[a-zA-Z]?[a-zA-Z0-9_-]*', 
      'action' => '[a-zA-Z]?[a-zA-Z0-9_-]*', 
     ], 
     'defaults' => [ 
      'controller' => 'index', 
      'action' => 'index', 
     ], 
    ], 
    'may_terminate' => true, 
    'child_routes' => [ 
     'id' => [ 
      'type' => 'Segment', 
      'priority' => 100, 
      'options' => [ 
       //'route' => '[/:id]', // this was changed without brackets (!) 
       'route' => '/:id', 
       'constraints' => [ 
        'id' => '[0-9]+', 
       ], 
       'defaults' => [ 
        'id' => '0', 
       ], 
      ], 
      'may_terminate' => true, 
      'child_routes' => [ 
       'wildcard' => [ 
        'type' => 'Wildcard', 
        'options' => [], 
       ], 
      ], 
     ], 
    ] 
] 
関連する問題