我正在尝试实现 Zend_Navigation – 通过本教程创建菜单和面包屑
在引导文件中,
...
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);
}
...
下面还有 application/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>
...
当我运行该站点时,出现以下错误,
致命错误:在 C:\xampp\htdocs\enit\library\Zend\Navigation\Page.php:235 中包含消息“无效参数:无法确定要实例化的类”的未捕获异常“Zend_Navigation_Exception”:235 堆栈跟踪:#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 ', 数组) #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 在第 235 行
我在stackoverflow和google上搜索了一些解决方案,但我找不到它。我做错了什么?好心劝告