2009年3月30日星期一

[fw-mvc] Accessing view placeholders in view helper called in layout

Hi guys,

I have problem with appending e.g. CSS files in view helper called in
layout.phtml

My example:

bootstrap:

$view = new Zend_View(array('encoding' => 'UTF-8'));
$view->addHelperPath(ROOT_DIR . '/app/www/views/helpers',
'Walk_View_Helper');
$view->addScriptPath(ROOT_DIR . '/app/www/views/scripts');
$view->doctype('XHTML1_STRICT');

$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);

$layout = Zend_Layout::startMvc(/path/to/layout.phtml);
$layout->setView($view);

layout.phtml:

<?php echo $this->doctype('XHTML1_STRICT'); ?>
<htm>
<head>
<?php echo $this->headLink(); ?>
</head>
<body>

<?php echo $this->myHelper(); ?>

</body>
</html>

MyHelper:

class Walk_MyHelper extends Zend_View_Helper_Abstract
{
public function myHelper()
{
$this->view->headLink()->appendStylesheet('/path/to/css');
return 'foo';
}
}

It seems helper "doesn't see" $this->view :(
--
View this message in context: http://www.nabble.com/Accessing-view-placeholders-in-view-helper-called-in-layout-tp22782923p22782923.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: