i will echo the headLink helper and after then I append to him another
stylesheets.
Well there are imho two possibilities:
a) change the helper to actions and use action stack plugin, which degrades
performance
b) split my view helpers to init() method called before echo of the headLink
and render() method which I insert to the place, where the html code should
be...
Another idea?
Best regards,
Václav Vaník
Václav Vaník wrote:
>
> Here is another problem... It is not necessary to add setView() method
> because my helper inherits Zend_View_Helper_Abstract
>
>
> Paweł Chuchmała wrote:
>>
>> Try add to your helper:
>> public $view;
>> and
>> public function setView(Zend_View_Interface $view)
>> {
>> $this->view = $view;
>> }
>>
>>
>> 2009/3/30 Václav Vaník <vanik@walk.cz>:
>>>
>>> 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.
>>>
>>>
>>
>>
>>
>> --
>> Paweł Chuchmała
>> pawel.chuchmala at gmail dot com
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Accessing-view-placeholders-in-view-helper-called-in-layout-tp22782923p22802238.html
Sent from the Zend MVC mailing list archive at Nabble.com.
没有评论:
发表评论