Zend 1.11 + Partial
Olá pessoal,
Sou iniciante em Zend Framework e estou tentando passar dados para um partial no layout. Minha estrutura está assim
application
-- layouts
-- scripts
backend.phtml
default.phtml
--modules
-- backend
-- controllers
IndexController.php
HomeController.php
-- views
-- scripts
-- index
index.phtml
-- home
index.phtml
-- partials
header.phtml
footer.phtml
-- default ...
No no layout eu tenho a seguinte estrutura
backend.phtml
<?php echo $this->doctype() ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Backend do projeto</title>
<?php echo $this->headLink()->appendStylesheet('/css/backend/homepage.css') ?>
</head>
<body>
<?php echo $this->layout()->content; ?>
</body>
</html>
é possivel eu inserir algo assim:
backend.phtml
<?php echo $this->doctype() ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Backend do projeto</title>
<?php echo $this->headLink()->appendStylesheet('/css/backend/homepage.css') ?>
</head>
<body>
[u]<?php echo $this->partial('partials/header.phtml')); ?>[/u]
<?php echo $this->layout()->content; ?>
[u]<?php echo $this->partial('partials/footer.phtml')); ?>[/u]
</body>
</html>
Sendo que em um partial eu teria algo assim:
header.phtml
<div id="header">
<h2>Usuário logado: <?php echo $this->usuario->nome ?></h2>
</div>
E no meu Controlador do backend/controllers/IndexController.php
<?php
class Backend_IndexController extends Zend_Controller_Action {
public function init() {
$this->_helper->layout->setLayout('backend');
if (!Zend_Auth::getInstance()->hasIdentity()) {
return $this->_helper->redirector->goToRoute(array(
'module' => 'backend',
'controller' => 'home',
'action' => 'index'), null, true);
} else {
$usuario = Zend_Auth::getInstance()->getIdentity();
$this->view->usuario = $usuario;
}
}
public function indexAction() {
}
}
No resumo da ópera, preciso passar valores ( variaveis ) para os partials que estão no layout. Qual a melhor saída para resolver isso???
obrigado
Discussão (1)
Carregando comentários...