Questions tagged [zend-view]

provides the “View” layer of Zend Framework 2’s MVC system. It is a multi-tiered system allowing a variety of mechanisms for extension, substitution, and more.

The components of the view layer are as follows:

  • Variables Containers hold variables and callbacks that you wish to represent in the view. Often-times, a Variables Container will also provide mechanisms for context-specific escaping of variables and more.
  • View Models hold Variables Containers, specify the template to use (if any), and optionally provide rendering options (more on that below). View Models may be nested in order to represent complex structures.
  • Renderers take View Models and provide a representation of them to return. Zend Framework 2 ships with three renderers by default: a PhpRenderer which utilizes PHP templates in order to generate markup, a JsonRenderer, and a FeedRenderer for generating RSS and Atom feeds.
  • Resolvers utilizes Resolver Strategies to resolve a template name to a resource a Renderer may consume. As an example, a Resolver may take the name “blog/entry” and resolve it to a PHP view script.
  • The View consists of strategies that map the current Request to a Renderer, and strategies for injecting the result of rendering to the Response.
  • Rendering Strategies listen to the “renderer” event of the View and decide which Renderer should be selected based on the Request or other criteria.
  • Response Strategies are used to inject the Response object with the results of rendering. That may also include taking actions such as setting Content-Type headers.
290 questions
60
votes
2 answers

How to switch layout files in Zend Framework?

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')…
Andrew
  • 227,796
  • 193
  • 515
  • 708
39
votes
8 answers

Sending variables to the layout in Zend Framework

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…
user138095
19
votes
7 answers

How do I use ViewScripts on Zend_Form File Elements?

I am using this ViewScript for my standard form elements:
element->getLabel())) : ?> formLabel($this->element->getName(),…
Sonny
  • 8,204
  • 7
  • 63
  • 134
15
votes
3 answers

Zend - how to disable layout on a given action?

I have the following controller that, among other methods it has this one: class EquipasController extends OccControllerAction { public function listaAction() { $this->_helper->viewRenderer->setNoRender(true); …
MEM
  • 30,529
  • 42
  • 121
  • 191
15
votes
4 answers

Force Canonical to use HTTPS

I want my customer section to be https, e.g. registration, login, personal details, order details, etc. I have set up my route to include the https scheme (I can access the customer section via https) but I cannot force my links to use https:
15
votes
1 answer

Get request info in view helper

Is it possible in Zend View helper (extends Zend_View_Helper_Abstract) get info about module/controller/action in which that helper was called ?
hsz
  • 148,279
  • 62
  • 259
  • 315
14
votes
1 answer

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

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?
Itay Moav -Malimovka
  • 52,579
  • 61
  • 190
  • 278
13
votes
3 answers

What do $this->escape() in zend framework actually do?

I need help in understanding the actual actions of a helper function in Zend Framework. I need someone to explain to me what $this->escape($string) actually does to the string passed to it before printing the string into the template.
IndexController
  • 589
  • 1
  • 10
  • 18
11
votes
6 answers

Getting basepath from view in zend framework

Case: you're developing a site with Zend Framework and need relative links to the folder the webapp is deployed in. I.e. mysite.com/folder online and localhost:8080 under development. The following works nice in controllers regardless of deployed…
Mads Mobæk
  • 34,762
  • 20
  • 71
  • 78
11
votes
3 answers

Zend Framework - Set No Layout for Controller

I have a Controller that I want to use for ajax scripts to call and set session variables, get information, etc. How do I set it so that that particular controller doesn't use the default layout (specifically NO layout) so that it can send XML/JSON…
ashurexm
  • 6,209
  • 3
  • 45
  • 69
10
votes
2 answers

How to use a partial view from a different module in Zend?

I'm trying to access a partial view in foo from another module bar. Simplified file structure: application/ modules/ foo/ index.phtml bar/ partial.phtml And in index.html you would have the following…
levivanzele
  • 726
  • 1
  • 13
  • 33
10
votes
3 answers

How do I extend the Zend Navigation Menu View Helper?

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…
Sonny
  • 8,204
  • 7
  • 63
  • 134
8
votes
2 answers

Step-by-step conversion to module-based folder structure for zend project

I'm looking for a step-by-step explanation on how to go from the normal folder structure on the left where the application folder contains models,views,controllers, to the module-based folder structure on the right where application contains a…
jblue
  • 4,390
  • 4
  • 46
  • 79
8
votes
1 answer

How to capture a Zend view output instead of actually outputting it

Problem: sometimes in our zend controller we don't want the script to be output directly, but rather want the content of that script. One example: when we need the result html output of a view script be included in another structure like JSON or XML…
Slavic
  • 1,891
  • 2
  • 16
  • 27
8
votes
4 answers

Zend Framework call view helper from a Zend_View_Helper

I have a helper called Zend_View_Helper_FormVars that's used by one of my modules. I also have a common helper in application/common/helpers/GeneralFunctions.php I'm trying to call a function from Zend_View_Helper_FormVars that's in …
EricP
  • 1,459
  • 6
  • 33
  • 55
1
2 3
19 20