zend-view

Zend Framework 2 - Set Template Path for Module

寵の児 提交于 2020-01-16 13:17:24
问题 I googled alot and couldn't come up with an answer... I'm using the tutorial-skeleton application. It automatically includes under 'view/album/album' the html files corresponding to my actions like add or index. I'm using a submodule and the standard loading won't find my html-files. I followed this guide for setting a custom template path. This works for the index because here I use a ViewModel instance. But my add/delete/edit actions just return an array like this one. Is there a way to

how to register new helper (custom helper ) in zend framework

跟風遠走 提交于 2020-01-06 08:19:09
问题 i have used $view->addHelperPath and registerHelper what i want is when i go to view scripts files and do this $this->[myhlper method] get the data from my helper class ! i tried to set the path in the application.ini but that dosn't work either,so how to do it ? 回答1: in your Bootstrap, add this method : protected function _initView() { $view = $this->bootstrap('layout')->getResource('layout')->getView(); $view->addHelperPath('Your/Custom/Path/', 'Your_Custom_Path'); $viewRenderer = new Zend

how I add view helper in zend

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-06 02:52:36
问题 I want to add custom view helper in zend framework like this: I placed in application.ini this code: includePaths.library = APPLICATION_PATH "/../library" and create library directory in myproject root create view helper TabEntry.php in library directory class Zend_View_Helper_TabEntry extends Zend_View_Helper_Abstract { public function TabEntry() { } } create another view helper TabEntries.php in library directory class Zend_View_Helper_TabEntries extends Zend_View_Helper_TabEntry { public

Using PhpRenderer directly with child views in ZF2

怎甘沉沦 提交于 2020-01-02 09:10:43
问题 When sending out e-mails in Zend Framework 2, I want to use view script templates such that I can leverage a layout for my various e-mail templates. The idea is that I have a layout which has the shared markup and echoes out content somewhere. Exactly how layouts work in general. To accomplish this, I am trying to add a child view model to my layout view model and render it with the PhpRenderer . public function someMethod() { $child = new ViewModel(); $child->setTemplate('test-template');

zend framework 2 get locale from view PhpRenderer

浪子不回头ぞ 提交于 2019-12-25 01:01:13
问题 How I can obtain traslator locale in my view? I want to do it starting from the variable $this (the PhpRenderer of the view). i.e. I don't want use onBootstrap nor ActionController because I don't care to have a view variables. Thank you! 回答1: You should try: <?php echo \Locale::getDefault(); ?> Many of the I18n classes make reference to PHP's Locale class (http://www.php.net/locale) - so in my opinion that would be a good starting point. 回答2: <?php echo $this->plugin('translate')-

Zend Framework: Check if Zend View Placeholder isset

只谈情不闲聊 提交于 2019-12-24 02:13:07
问题 How can I check if a Zend View Placeholder isset before echo-ing it out? As I am wanting to prepend " - " to it before outputting it. I tried echo isset($this->placeholder('title')) ? ' - ' . $this->placeholder('title') : ''; But I got Fatal error: Can't use method return value in write context in D:\Projects\Websites\php\ZendFramework\LearningZF\application\layouts\scripts\layout.phtml on line 5 On a side note, how come when I got this error, why isn't it shown in the Error View Script? The

Modify Stack in the Zend HeadScript View Helper

依然范特西╮ 提交于 2019-12-22 12:53:49
问题 I am trying to attack this problem from a completely different angle, because it doesn't look like I can achieve my goal that way. I want to loop over the item stack in the HeadScript View Helper, and make modifications to it. The documentation for this and some of the other view helpers makes this statement: HeadScript overrides each of append(), offsetSet(), prepend(), and set() to enforce usage of the special methods as listed above. Internally, it stores each item as a stdClass token,

Modify Stack in the Zend HeadScript View Helper

痞子三分冷 提交于 2019-12-22 12:53:03
问题 I am trying to attack this problem from a completely different angle, because it doesn't look like I can achieve my goal that way. I want to loop over the item stack in the HeadScript View Helper, and make modifications to it. The documentation for this and some of the other view helpers makes this statement: HeadScript overrides each of append(), offsetSet(), prepend(), and set() to enforce usage of the special methods as listed above. Internally, it stores each item as a stdClass token,

multiple instances of view helper plugin?

时光怂恿深爱的人放手 提交于 2019-12-22 11:46:51
问题 How do I instantiate multiple instances of a view helper plugin in Zend 2? I want to return a new instance every time I call $this->pluginName(); from the view. How do I return a new instance of the view plugin? 回答1: Add the service name to the getViewHelperConfig() shared configuration key in Module.php and set this value to false Module.php function getViewHelperConfig() { return array( 'shared' => array( 'MyViewHelper' => false, ), 'factories' => array( 'MyViewHelper' => 'App\View\Helper

Override Separator on Zend_Form Radio Elements When Using a ViewScript Decorator

安稳与你 提交于 2019-12-21 23:57:25
问题 I am using ViewScripts to decorate my form elements. With radio elements, the separator can normally be overridden, but the override is being ignored when I use the ViewScript. When I use the below call and ViewScript, the radio elements are separated by a '<br />' rather than the space I've specified. If leave the default decorators, the override works. $this->addElement('radio', 'active', array( 'disableLoadDefaultDecorators' => true, 'decorators' => array(array('ViewScript', array(