我在當前的Zend Framework應用程序中遇到問題。Zend_Controller_Router_Exception:未指定「xyz」
在我引導我註冊這些路線:
protected function _initRouter()
{
$this->bootstrap("FrontController");
$frontController = $this->getResource("FrontController");
$route = new Zend_Controller_Router_Route(
":module/:id",
array(
"controller" => "index",
"action" => "index"
),
array("id" => "\d+")
);
$frontController->getRouter()->addRoute('shortcutOne', $route);
$route = new Zend_Controller_Router_Route(
":module/:controller/:id",
array("action" => "index"),
array("id" => "\d+")
);
$frontController->getRouter()->addRoute('shortcutTwo', $route);
$route = new Zend_Controller_Router_Route(
":module/:controller/:action/:id",
null,
array("id" => "\d+", "action" => "\w+")
);
$frontController->getRouter()->addRoute('shortcutThree', $route);
}
現在以後我加Zend_Navigation到我的項目。我有幾個模塊,在該模塊引導註冊導航元素:
<?php
class Contact_Bootstrap extends Zend_Application_Module_Bootstrap
{
protected function _initNavigation()
{
$layout = $this->getApplication()->getResource("layout");
$view = $layout->getView();
$config = new Zend_Config_Xml(dirname(__FILE__)."/config/navigation.xml", "nav");
$view->navigation()->addPage($config);
}
}
當我在瀏覽器中打開應用程序,一切工作正常。這意味着我可以看到導航並單擊其鏈接來查看指定的頁面。但是,當我打了使用頁面:模塊/:動作/:身份證路線,導航助手拋出一個異常Zend_Controller_Router_Route中:
Fatal error: Zend_Controller_Router_Exception: id is not specified in C:\Entwicklung\kt\trunk\src\library\Zend\View\Helper\Navigation\HelperAbstract.php on line 519
難道有人對你遇到這個錯誤嗎?如果你能幫助我或給我建議,那將是非常棒的。另外,如果您需要更多關於我的設置等信息,請告訴我。
謝謝!
嗨基督徒! 我很高興我可以幫助您解決我的問題。 – 2010-02-17 11:30:51
通過一些工作,這個答案歸結爲:給你的導航頁面一個明確的路線。否則,它將遍歷所有路線/選擇第一個,試圖強制導航URL進入該路線。如果該路線具有必需/非默認參數,那麼它將給出該例外,而不是智能地實現路線不適當。 (讓我走上正確的道路+1) – Zimzat 2011-10-01 21:50:05