Zend 框架导航错误,有人可以帮忙吗?

发布于 2024-12-01 12:39:17 字数 2715 浏览 0 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

难以启齿的温柔 2024-12-08 12:39:17

如果我不得不猜测,我会说是这个,

$_auth->getStorage()->read()->uid

因为这是在该行上获取类属性的唯一尝试(其他都是方法)。

看来 Zend_Auth_Storage_Interface::read() 返回的任何内容都不是对象。由于这是您在自己的代码中设置的内容,因此除了调试 read() 的返回值之外,我无法提供任何进一步的建议。

更新

我会尝试像这样修复它,但在不了解有关您的应用程序的更多信息的情况下,我只是猜测。

$_auth = Zend_Auth::getInstance();

$uid = $_auth->hasIdentity() ? $_auth->getIdentity()->uid : null;

echo $this->navigation()->menu()->setAcl($obj_menuacl)->setRole($uid);

If I had to guess, I'd say it was this

$_auth->getStorage()->read()->uid

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 of read().

Update

I'd attempt to fix it like this but without knowing more about your application, I'm only guessing.

$_auth = Zend_Auth::getInstance();

$uid = $_auth->hasIdentity() ? $_auth->getIdentity()->uid : null;

echo $this->navigation()->menu()->setAcl($obj_menuacl)->setRole($uid);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文