Zend 框架导航错误,有人可以帮忙吗?
http://site2.example.com/ 错误=>
Notice: Trying to get property of non-object in /var/www/site/application/layouts/scripts/layout.phtml on line 19 Call Stack: 0.0003 335220
1. {main}() /var/www/site/public/index.php:0 0.0710 4242640
2. Zend_Application->run() /var/www/site/public/index.php:26 0.0710 4242640
3. Zend_Application_Bootstrap_Bootstrap->run() /var/www/site/library/Zend/Application.php:366 0.0711 4242712
4. Zend_Controller_Front->dispatch() /var/www/site/library/Zend/Application/Bootstrap/Bootstrap.php:97 0.1046 5601136
5. Zend_Controller_Plugin_Broker->postDispatch() /var/www/site/library/Zend/Controller/Front.php:965 0.1046 5601136
6. Zend_Layout_Controller_Plugin_Layout->postDispatch() /var/www/site/library/Zend/Controller/Plugin/Broker.php:331 0.1048 5601500
7. Zend_Layout->render() /var/www/site/library/Zend/Layout/Controller/Plugin/Layout.php:143 0.1056 5605568
8. Zend_View_Abstract->render() /var/www/site/library/Zend/Layout.php:796 0.1057 5646952
9. Zend_View->_run() /var/www/site/library/Zend/View/Abstract.php:880 0.1060 5662656
10. include('/var/www/site/application/layouts/scripts/layout.phtml') /var/www/site/library/Zend/View.php:108
这是代码 =>
<head>
<?php echo $this->headScript()->appendFile($this->baseUrl() . '/js/jwplayer.js'); ?>
<?php echo $this->headScript()->appendFile($this->baseUrl() . '/js/swfobject.js'); ?>
<?php echo $this->headLink()->prependStylesheet($this->baseUrl().'/css/topmenu.css'); ?>
</head>
<?php
$flXml=new Zend_Config_Xml(APPLICATION_PATH.'/configs/navigation.xml','nav');
$container = new Zend_Navigation($flXml);
Zend_Registry::set('Zend_Navigation', $container);
?>
<div id="nav-menu">
<?php
$obj_menuacl=new Model_MenuAcl();
$_auth=Zend_Auth::getInstance();
echo $this->navigation()->menu()->setAcl($obj_menuacl)->setRole($_auth->getStorage()->read()->uid);
echo $this->loggedInAs();
echo '<br><br>';
echo 'You are in: ' . $this->navigation()->breadcrumbs()->setLinkLast(false)->setMinDepth(0)->render();
?>
</div>
<div class="mainbody"><?php echo $this->layout()->content; ?></div>
<br />
我应该怎么办 ?
错误在哪里?
这是行号 19 =>
echo $this->navigation()->menu()->setAcl($obj_menuacl)->setRole($_auth->getStorage()->read()->uid);
如果我尝试打印它=> echo $_auth->getStorage(); <=它会产生该错误消息。
http://site2.example.com/
Error=>
Notice: Trying to get property of non-object in /var/www/site/application/layouts/scripts/layout.phtml on line 19 Call Stack: 0.0003 335220
1. {main}() /var/www/site/public/index.php:0 0.0710 4242640
2. Zend_Application->run() /var/www/site/public/index.php:26 0.0710 4242640
3. Zend_Application_Bootstrap_Bootstrap->run() /var/www/site/library/Zend/Application.php:366 0.0711 4242712
4. Zend_Controller_Front->dispatch() /var/www/site/library/Zend/Application/Bootstrap/Bootstrap.php:97 0.1046 5601136
5. Zend_Controller_Plugin_Broker->postDispatch() /var/www/site/library/Zend/Controller/Front.php:965 0.1046 5601136
6. Zend_Layout_Controller_Plugin_Layout->postDispatch() /var/www/site/library/Zend/Controller/Plugin/Broker.php:331 0.1048 5601500
7. Zend_Layout->render() /var/www/site/library/Zend/Layout/Controller/Plugin/Layout.php:143 0.1056 5605568
8. Zend_View_Abstract->render() /var/www/site/library/Zend/Layout.php:796 0.1057 5646952
9. Zend_View->_run() /var/www/site/library/Zend/View/Abstract.php:880 0.1060 5662656
10. include('/var/www/site/application/layouts/scripts/layout.phtml') /var/www/site/library/Zend/View.php:108
This is the code =>
<head>
<?php echo $this->headScript()->appendFile($this->baseUrl() . '/js/jwplayer.js'); ?>
<?php echo $this->headScript()->appendFile($this->baseUrl() . '/js/swfobject.js'); ?>
<?php echo $this->headLink()->prependStylesheet($this->baseUrl().'/css/topmenu.css'); ?>
</head>
<?php
$flXml=new Zend_Config_Xml(APPLICATION_PATH.'/configs/navigation.xml','nav');
$container = new Zend_Navigation($flXml);
Zend_Registry::set('Zend_Navigation', $container);
?>
<div id="nav-menu">
<?php
$obj_menuacl=new Model_MenuAcl();
$_auth=Zend_Auth::getInstance();
echo $this->navigation()->menu()->setAcl($obj_menuacl)->setRole($_auth->getStorage()->read()->uid);
echo $this->loggedInAs();
echo '<br><br>';
echo 'You are in: ' . $this->navigation()->breadcrumbs()->setLinkLast(false)->setMinDepth(0)->render();
?>
</div>
<div class="mainbody"><?php echo $this->layout()->content; ?></div>
<br />
What should i do ?
Where is the error ?
This is the line number 19 =>
echo $this->navigation()->menu()->setAcl($obj_menuacl)->setRole($_auth->getStorage()->read()->uid);
If i try to print it=> echo $_auth->getStorage(); <=it results that error message.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我不得不猜测,我会说是这个,
因为这是在该行上获取类属性的唯一尝试(其他都是方法)。
看来
Zend_Auth_Storage_Interface::read()
返回的任何内容都不是对象。由于这是您在自己的代码中设置的内容,因此除了调试read()
的返回值之外,我无法提供任何进一步的建议。更新
我会尝试像这样修复它,但在不了解有关您的应用程序的更多信息的情况下,我只是猜测。
If I had to guess, I'd say it was this
as this is the only attempt to get a class property on that line (everything else is a method).
It seems that whatever is returned by
Zend_Auth_Storage_Interface::read()
is not an object. As this is something you set in your own code, I cannot offer any further advice other than to debug the return value ofread()
.Update
I'd attempt to fix it like this but without knowing more about your application, I'm only guessing.