1

このようにいくつかのモジュールを備えたZFアプリがあります:(いつものように)

root\
    \application\
                \default
                \items
                \me
                   \controllers
                   \views

アプリケーションは、次のようなデフォルト ルーティングを使用します/module/controller/action

私が欲しいのはこれです:デフォルトのZendルーティングに一致するものが見つからない場合(アクション/コントローラー/モジュールが見つからない)、パラメーターに吐き出されたurlエンドポイントを使用して目的のパスにルーティングします。

例えば:

  • mydomain.lh/meme-> module 、 controller index、 actionに一致しますindex(デフォルト)

  • mydomain.lh/my_category_name-> module items、 controller index、 action indexparams: category => my_category_name ->目的のパスrouteを使用して一致します

    • my_category_name照合するモジュールが存在しません

私はこれをbootstrap.phpに試しました:

 public function _initRoutes ()
{
    $router = $this->_front->getRouter(); // returns a rewrite router by default

    $router->addRoute(
        'cat-item',
        new Zend_Controller_Router_Route('/:category',
                                         array(
                                            'module' => 'items',
                                            'controller' => 'index',
                                            'action' => 'index'))
    );
}

魔女は正しい場所を指しています (リクエスト URL をアクションに var_dump -ed し、予想される URL とパラメーターがそこにあったのでわかりますが、アクションに入れitems/index/indexないvar_dump(something);exit;と、空白のページが表示されます。

  • 出力は行われませんが、エラーも生成されません。リクエストのステータスは 200 - OK です。

誰でも提案できますか?

ありがとうございました!

4

0 に答える 0