zend-view

How do I use ViewScripts on Zend_Form File Elements?

元气小坏坏 提交于 2019-11-27 00:47:10
I am using this ViewScript for my standard form elements: <div class="field" id="field_<?php echo $this->element->getId(); ?>"> <?php if (0 < strlen($this->element->getLabel())) : ?> <?php echo $this->formLabel($this->element->getName(), $this->element->getLabel());?> <?php endif; ?> <span class="value"><?php echo $this->{$this->element->helper}( $this->element->getName(), $this->element->getValue(), $this->element->getAttribs() ) ?></span> <?php if (0 < $this->element->getMessages()->length) : ?> <?php echo $this->formErrors($this->element->getMessages()); ?> <?php endif; ?> <?php if (0 <

How to add custom view helpers to Zend Framework 2

让人想犯罪 __ 提交于 2019-11-26 21:03:29
问题 I have earlier asked this question, and I got good answers there. However, that was for beta4, and no longer works. So where and how do I add my own view helpers to ZF2? 回答1: You should add them to your module.config.php under view_helpers like this: 'view_manager' => array( 'template_path_stack' => array( 'ModuleName' => __DIR__ . '/../view', ), ), 'view_helpers' => array( 'factories' => array( 'showmessages' => function($sm) { $helper = new ModuleName\Helper\MessageShower(); // do stuff

How do I extend the Zend Navigation Menu View Helper?

流过昼夜 提交于 2019-11-26 14:51:18
问题 I need to change the output of Zend_View_Helper_Navigation_Menu . I've found the two functions that I'll need to modify, and I know how to make the changes I need. What I don't know is how to make the Navigation object use my view helper instead of the Zend one. Code snippet representing my class extension: // file /library/My/View/Helper/Navigation/Menu.php class My_View_Helper_Navigation_Menu extends Zend_View_Helper_Navigation_Menu { protected function _renderDeepestMenu(Zend_Navigation

How do I use ViewScripts on Zend_Form File Elements?

帅比萌擦擦* 提交于 2019-11-26 09:27:36
问题 I am using this ViewScript for my standard form elements: <div class=\"field\" id=\"field_<?php echo $this->element->getId(); ?>\"> <?php if (0 < strlen($this->element->getLabel())) : ?> <?php echo $this->formLabel($this->element->getName(), $this->element->getLabel());?> <?php endif; ?> <span class=\"value\"><?php echo $this->{$this->element->helper}( $this->element->getName(), $this->element->getValue(), $this->element->getAttribs() ) ?></span> <?php if (0 < $this->element->getMessages()-

Sending variables to the layout in Zend Framework

非 Y 不嫁゛ 提交于 2019-11-26 08:09:36
问题 In my project I have a number of dynamic elements that are consistently on every page. I have put these in my layout.phtml My question is: How can I send variables into my layout from my controllers? If I want to send things from my controller I can use: $this->view->whatever = \"foo\"; And receive it in the view with echo $this->whatever; I cannot figure out how to do the same with my layout. Perhaps there is a better way around the problem? 回答1: The layout is a view, so the method for