我想實現Zend_Navigation - 此tutorialZend的導航問題與Zend_Config_Xml中
在引導文件創建菜單,麪包屑,
...
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
protected $_config;
protected $_layout;
protected function _initConfig() {
$this->_config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini');
Zend_Registry::set("config", $this->_config);
if ($this->_config->debug) {
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 'on');
}
$request = new Zend_Controller_Request_Http();
$uri = $request->getRequestUri();
if (preg_match("/admin/", $uri)) {
//echo $this->_config->layout->admin->layout; exit;
$this->_layout = Zend_Layout::startMvc(
array(
'layoutPath' => $this->_config->layout->layoutPath,
'layout' => $this->_config->layout->admin->layout
)
);
} else {
$this->_layout = Zend_Layout::startMvc(
array(
'layoutPath' => $this->_config->layout->layoutPath,
'layout' => $this->_config->layout->layout)
);
//echo $this->_view = $this->_layout->getView(); exit;
}
}
/**
* used for handling top-level navigation
* @return Zend_Navigation
*/
protected function _initNavigation()
{
$view = $this->_layout->getView();
/*
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
*/
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml','nav');
$container = new Zend_Navigation($config);
$view->navigation($container);
}
...
下面還正在申請/ config中的navigation.xml文件夾
<?xml version="1.0" encoding="UTF-8"?>
<configdata>
<nav>
<home>
<label>Home</label>
<uri>/</uri>
<pages>
<index>
<label>Home</label>
<uri>/index/index</uri>
</index>
<index>
<label>Product</label>
<uri>/index/product</uri>
</index>
</pages>
</home>
</nav>
</configdata>
在版式文件
...
<div class="breadcrumbs">
<?= $this->navigation()->breadcrumbs()->setMinDepth(0)->setLinkLast(true)->setSeparator(" : "); ?>
</div>
...
,當我跑的網站,我得到了以下錯誤,
Fatal error: Uncaught exception 'Zend_Navigation_Exception' with message 'Invalid argument: Unable to determine class to instantiate' in C:\xampp\htdocs\enit\library\Zend\Navigation\Page.php:235 Stack trace: #0 C:\xampp\htdocs\enit\library\Zend\Navigation\Container.php(117): Zend_Navigation_Page::factory(Array) #1 C:\xampp\htdocs\enit\library\Zend\Navigation\Container.php(164): Zend_Navigation_Container->addPage(Array) #2 C:\xampp\htdocs\enit\library\Zend\Navigation\Container.php(179): Zend_Navigation_Container->addPages(Array) #3 C:\xampp\htdocs\enit\library\Zend\Navigation\Page.php(852): Zend_Navigation_Container->setPages(Array) #4 C:\xampp\htdocs\enit\library\Zend\Navigation\Page.php(295): Zend_Navigation_Page->set('pages', Array) #5 C:\xampp\htdocs\enit\library\Zend\Navigation\Page.php(250): Zend_Navigation_Page->setOptions(Array) #6 C:\xampp\htdocs\enit\library\Zend\Navigation\Page.php(232): Zend_Navigation_Page->__construct(Array) #7 C:\xampp\htdocs\enit\library\Zend\Navigation\Container.php(117): Zend_Navigation_P in C:\xampp\htdocs\enit\library\Zend\Navigation\Page.php on line 235
我搜索了計算器,以及谷歌的一些解決方案,但我找不到it.what我做錯了這個?請建議
根據你有兩個節點,嘗試和重命名他們 –
Ashley
2012-04-15 15:14:32
@Ashley謝謝,現在錯誤已被修復 – mymotherland 2012-04-15 15:58:12