zend-view

ZF2 - How to change the error/404 response page? Not just template but to set a new ViewModel

ε祈祈猫儿з 提交于 2019-12-04 08:55:38
By default the page is set like this in the Application module.config array: 'template_map' => array( 'error/404' => __DIR__ . '/../view/error/404.phtml' I want to change the page. I want new ViewModel for it full of variables. It means that simply to change the template is not enough: 'error/404' => __DIR__ . '/../view/error/my_new_404_template.phtml' But I can't understand how to make it. I can't see the way the request comes to the 'error/404' . How to create new ViewModel for it? How to attach variables to it? How the route comes to 'error/404' to catch it to change? For example, I have

Autocompletion for ZF2 view helpers in PhpStorm

醉酒当歌 提交于 2019-12-04 08:47:36
Does anyone know if PHPStorm has some builtin support for view helper autocompletion or a possibility to write a plugin for it. I don't want to use inline var definitions for this as this would be cumbersome to do if I use a lot of view helpers $this->inlineScript()-> //I want some autocomplete here. $this->translate('some translation')-> //Please give me autocompletion If I use var definitions it will end up as something like this, but it will really clutter up my view: /* @var $inlineScript \Zend\View\Helper\InlineScript */ $inlineScript = $this->inlineScript(); $inlineScript-> //Now I have

How to switch layout files in Zend Framework?

我的梦境 提交于 2019-12-04 07:36:49
问题 I'm sure it's a simple one-liner, but I can't seem to find it. How can I use a different layout file for a particular action? Update: This worked for me, thanks! // Within controller $this->_helper->_layout->setLayout('other-layout') //other-layout.phtml //Within view script <?php $this->layout()->setLayout('other-layout'); ?> 回答1: From inside a Controller: $this->_helper->layout->setLayout('/path/to/your/layout_script'); (via these docs) EDIT: I should mention that the path is relative to

Getting View Object from within a Zend Controller plugin

自作多情 提交于 2019-12-01 08:15:11
In my controller, I have a postDispatch to consolidate my FlashMessenger messages: public function postDispatch() { $messages = $this->_helper->getHelper ( 'FlashMessenger' ) ->getMessages (); if ( $this->_helper->getHelper ( 'FlashMessenger' ) ->hasCurrentMessages () ) { $messages = array_merge ( $messages, $this->_helper->getHelper ( 'FlashMessenger' ) ->getCurrentMessages () ); $this->_helper->getHelper ( 'FlashMessenger' ) ->clearCurrentMessages (); } $this->view->alert = $messages; } I want to make this into a Controller plugin. UPDATE: I realized why I need this - I want to pass my flash

Getting View Object from within a Zend Controller plugin

眉间皱痕 提交于 2019-12-01 07:07:46
问题 In my controller, I have a postDispatch to consolidate my FlashMessenger messages: public function postDispatch() { $messages = $this->_helper->getHelper ( 'FlashMessenger' ) ->getMessages (); if ( $this->_helper->getHelper ( 'FlashMessenger' ) ->hasCurrentMessages () ) { $messages = array_merge ( $messages, $this->_helper->getHelper ( 'FlashMessenger' ) ->getCurrentMessages () ); $this->_helper->getHelper ( 'FlashMessenger' ) ->clearCurrentMessages (); } $this->view->alert = $messages; } I

Zend Framework: Render multiple Views in one Layout

假装没事ソ 提交于 2019-11-30 11:09:44
问题 I want to generate a dynamic site using Zend_Layout. My layout (/application/layouts/scripts/layout.phtml) contains the following lines: ... <body> <?php echo $this->render('header.phtml') ?> <div id="content"><?php echo $this->layout()->content ?></div> <?php echo $this->render('footer.phtml') ?> </body> ... If i browse to my index controller index action - Zend renders the index view (application/views/scripts/index/index.phtml) inside of $this->layout()->content automatically. Now i want

understanding grid layout in zend

↘锁芯ラ 提交于 2019-11-30 09:46:09
问题 I'm a bit confused with designing forms in zend. I understood that I have the fields in my form class and the look should be done in the views. In the index view which is nearly plain html I don't have problems, but in the add and edit views which show my form I have problems to change the look. I have a viewscript like follows: <?php $title = 'AVB ändern'; $this->headTitle($title); ?> <h1><?= $this->escapeHtml($title) ?></h1> <?php $id= $form->get('id'); $id->setAttribute('class', 'form

Zend Framework - Last Code to Execute Before Layout is Rendered

时光怂恿深爱的人放手 提交于 2019-11-29 12:51:30
I want to execute some code right before the layout is rendered, after all other code is executed. Where would I put that code? I am specifically trying to modify the files referenced in the headLink, headScript, and inlineScript view helpers before they're used by the layout. Here are the steps I want to take: Loop over the files in those view helpers Make a list of the local files Remove local files from the view helpers Reference the local file list as a parameter to a server script that combines them for a single HTTP request Add that new combine script reference to the appropriate view

Zend Framework - Last Code to Execute Before Layout is Rendered

孤人 提交于 2019-11-28 06:18:38
问题 I want to execute some code right before the layout is rendered, after all other code is executed. Where would I put that code? I am specifically trying to modify the files referenced in the headLink, headScript, and inlineScript view helpers before they're used by the layout. Here are the steps I want to take: Loop over the files in those view helpers Make a list of the local files Remove local files from the view helpers Reference the local file list as a parameter to a server script that

How to add custom view helpers to Zend Framework 2

拟墨画扇 提交于 2019-11-27 22:34:27
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? 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 with $sm or the $helper return $helper; }, ), 'invokables' => array( 'selectmenu' => 'ModuleName\Helper