rat_clot 0 Posted April 5, 2011 Report Share Posted April 5, 2011 Boas, sou iniciante em Zend Framework, e estou com um erro que não consigo resolver nem encontrar solução na net. Quero alterar o layout do site quando alguém está logado. Este é o meu ficheiro bootstrap: <?php class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initAuthState() { if (Zend_Auth::getInstance()->hasIdentity()): // Logged in. $layout->setLayout(‘layout2’); else: // Not Logged in. $layout->setLayout(‘layout’); endif; } } Este é o erro que me dá: Fatal error: Call to a member function setLayout() on a non-object in /home/zerego/application/Bootstrap.php on line 13 Se alguém souber qual é o problema agradecia. Fiquem bem Link to post Share on other sites
yoda 126 Posted April 5, 2011 Report Share Posted April 5, 2011 O $layout não é instância de nada, precisas iniciar o objecto. before you post, what have you tried? - http://filipematias.info sense, purpose, direction Link to post Share on other sites
rat_clot 0 Posted April 5, 2011 Author Report Share Posted April 5, 2011 Obrigado Yoda, desculpa lá mas eu sou mesmo iniciante nisto, e também só tive aulas de php durante uns 6 meses ou pouco mais. agora estou com outro erro, que supostamente o layout2.phtml não existe na pasta: Fatal error: Uncaught exception 'Zend_View_Exception' with message 'script '‘layout2’.phtml' not found in path (/layouts/scripts/:./views/scripts/)' in /home/zerego/library/Zend/View/Abstract.php:976 Stack trace: #0 /home/zerego/library/Zend/View/Abstract.php(876): Zend_View_Abstract->_script('?layout2?.phtml') #1 /home/zerego/library/Zend/Layout.php(796): Zend_View_Abstract->render('?layout2?.phtml') #2 /home/zerego/application/Bootstrap.php(13): Zend_Layout->render() #3 /home/zerego/library/Zend/Application/Bootstrap/BootstrapAbstract.php(662): Bootstrap->_initAuthState() #4 /home/zerego/library/Zend/Application/Bootstrap/BootstrapAbstract.php(615): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('authstate') #5 /home/zerego/library/Zend/Application/Bootstrap/BootstrapAbstract.php(579): Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap(NULL) #6 /home/zerego/library/Zend/Application.php(355): Zend_Application_Bootstrap_BootstrapAbstract->bootstrap(NULL) #7 /home/zerego/public_html/index.php(25): Zen in /home/zerego/library/Zend/View/Abstract.php on line 976 Eu tenho criado o layout2.phtml e está na mesma pasta que o layout.phtml. O caminho que tenho definido no "aplications.ini" é este: resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/" O bootstrap está assim: <?php class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initAuthState() { $layout = new Zend_Layout; $layout->setLayoutPath('/layouts/scripts'); if (Zend_Auth::getInstance()->hasIdentity()): // Logged in. $layout->setLayout(‘layout2’); $layout->render(); else: // Not Logged in. $layout->setLayout(‘layout’); endif; } } Se me conseguirem ajudar outra vez, agradecia. Fiquem bem Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now