zend-view

Where do I save partial (views) in Zend Framework, to be accessible for all Views in my App?

一世执手 提交于 2019-12-18 02:37:36
问题 I have several view Partials (like paginator partial) which I want them to be available To all view scripts in my application. Is there a directory I can put partial vies in, and they will be available to all? Or, how do I define such a directory? 回答1: You can create a folder in the views folder with any name and from your views you would call a partial using the following code and as the second argument pass an array of values which would be used within the partial. $this->partial('your

How capture the default.phtml in a variable inside a controller

走远了吗. 提交于 2019-12-12 18:52:05
问题 I have a simple question... How could I render the contents of the default.phtml which is in Project/application/layouts/scripts/default.phtml to a variable, so I can have its html. In the index controller, with an action and a phtml file named test, this would work: $html = $this->view->render('index/test.phtml'); But, of course, this does not: $htmlDefaultLayout = $this->view->render('default.phtml'); Since default.phtml is not inside any controller, I guess. Is there a good way to do that?

How to add custom view helpers to Zend Framework 2 (beta 4)

半城伤御伤魂 提交于 2019-12-12 03:47:25
问题 NOTE: This is an old question and the answers here no longer works (since beta5). See this question on how to do it with ZF2 stable version. I have looked at this example from the manual. Note that this is version 2 of the Zend Framework. I create this helper: <?php namespace Mats\Helper; use Zend\View\Helper\AbstractHelper; class SpecialPurpose extends AbstractHelper { protected $count = 0; public function __invoke() { $this->count++; $output = sprintf("I have seen 'The Jerk' %d time(s).",

Zend Framework Create Custom View Helper?

梦想的初衷 提交于 2019-12-11 11:30:51
问题 I have tried multiple fixes but none have worked. I am getting this error: Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception' with message 'Plugin by name 'AddCss' was not found in the registry; used paths: Zend_View_Helper_: Zend/View/Helper/:/Users/cgunnels/dev/git/rove-git/application/views/helpers/' in /usr/local/zend/share/ZendFramework/library/Zend/Loader/PluginLoader.php:412 Stack trace: #0 /usr/local/zend/share/ZendFramework/library/Zend/View/Abstract.php(1182): Zend

ZF2 : disable error page layout

偶尔善良 提交于 2019-12-11 11:07:25
问题 im trying to disable layout while showing error/exception page in my zf2 module but nothing works please help 回答1: Final Solution in my Module.php $eventManager = $e->getApplication()->getEventManager(); $eventManager->attach(MvcEvent::EVENT_DISPATCH_ERROR, function($e) { $result = $e->getResult(); $result->setTerminal(TRUE); }); it works and only loads error/404 view file not the layout file thanks andrew 回答2: If you look at the Zend Framework 2 MVC module you will see possibilities for this

How do I pass variables to a layout in a multiple module / layout Zend Framework application?

夙愿已清 提交于 2019-12-11 05:36:02
问题 Before I converted my Zend Framework application to a module based structure, it had a single layout and I could pass variables to it from my controller like so: // Controller action $this->view->foo = 'Something'; // Layout <?= $this->foo ?> However, since moving everything into a default module and creating a separate "admin" module, I can no longer get this to work, most likely due to me moving my "View Settings" out of my bootstrap file and into the controller plugin where I am switching

Zend_Form:: When should be form created in view and not in controller?

岁酱吖の 提交于 2019-12-11 00:06:17
问题 Zend_Form:: When should be form created in view and not in controller? option 1 - form created in controller and passed to view (usually used) controller: $form=new MyForm(); $this->view->form=$form; view: echo $this->form; option 2 - form created in view directly (looks better to me because form its subpart of view) view: $form=new MyForm(); echo $this->form; Thanks 回答1: In short: newer in view . You may eventually: create view helper for complex tasks (and call the helper in view $this-

How to get code completion for variables into zend_view using netbeans 6.9.1?

家住魔仙堡 提交于 2019-12-09 23:55:53
问题 i'm evaluating to switch to netbeans ide for managing my zend_framework project; i'd like to have autocompletion for variable's name into my view, for variables defined in actions as i see in this screencast, http://netbeans.org/kb/docs/php/zend-framework-screencast.html , but i can't figure out. When i digit $this-> in any view i can't see none variable's name. I'd like a lot to use this feature. Thank you, Mirco. 回答1: You need to have Zend Framework either in the include path for the

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

若如初见. 提交于 2019-12-09 18:27:54
问题 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

Zend Framework 2 Service in View Helper

无人久伴 提交于 2019-12-07 09:15:00
问题 I need to write a view helper that gets a service and do something with it. I successfully implemented the view helper to have access to the service locator. The problem is that the service I want to get is not being found through the service locator when the __invoke method is called. The view helper code: <?php namespace Application\View\Helper; use Zend\View\Helper\AbstractHelper, Zend\ServiceManager\ServiceLocatorAwareInterface, Application\Model; class LoggedCustomer extends