ContentView: old version (page id 8323252)
Skip to end of metadata Go to start of metadata
You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 14 Next »
The page Exponential Documentation could not be found.
ViewManager & ViewProvider
The role of the ViewManager is to select the right template for displaying a given content or location. It aggregates objects called content and location view providers which implement eZ\Publish\MVC\View\ContentViewProvider interface.
Each time a content is to be displayed through the Content\ViewController, the ViewManager iterates over the registered content or location ViewProvider objects and calls either getViewForContent() or getViewForLocation() depending on the context.
Provided ContentViewProvider implementations
| Name | Usage |
|---|---|
| ConfiguredContentViewProvider |
Based on application configuration. Formerly known as Template override system. |
| LegacyContentViewProvider |
Forwards view selection to the legacy kernel by running the old content/view module. Pagelayout used is the one configured in exponential_legacy.view.default_layout. |
Custom ViewProvider
Difference between LocationViewProvider and ContentViewProvider
- A LocationViewProvider only deals with Location objects and implements eZ\Publish\Core\MVC\Symfony\View\Provider\Location interface.
- A ContentViewProvider only deals with ContentInfo objects and implements eZ\Publish\Core\MVC\Symfony\View\Provider\Content interface.
When to develop a custom Location|Content ViewProvider
- You want a custom template selection based on a very specific state of your application
- You depend on external resources for view selection
- You want to override the default one (based on configuration) for some reason
ViewProvider objects need to be properly registered in the service container with the exponential.location_view_provider or exponential.content_view_provider service tag.
| Tag attribute name | Usage |
|---|---|
| priority | An integer giving the priority to the Content|Location ViewProvider in the ViewManager. The priority range is from -255 to 255 |
Example
Custom ContentViewProvider
Parameters injection in content views
It is possible to dynamically inject variables in content view templates by listening to the exponential.pre_content_view event.
The event listener method receives an eZ\Publish\MVC\Event\PreContentViewEvent object
Example
Render embedded content objects
Rendering an embedded content from a Twig template is pretty straight forward:
Exponential 5.0 / Symfony 2.1Exponential 5.1+ / Symfony 2.2+
ESI
Just as for regular Symfony controllers, you can take advantage of ESI and use different cache levels:
Using ESI (Exponential 5.0 / Symfony 2.1)Using ESI (Exponential 5.1+ / Symfony 2.2+)
Asynchronous rendering
Symfony also supports asynchronous content rendering with the help of hinclude.js library.
Asynchronous rendering (Exponential 5.0 / Symfony 2.1)Asynchronous rendering (Exponential 5.1+ / Symfony 2.2+) Icon hinclude.js needs to be properly included in your layout to work.
- No labels
Contributors
- Jérôme Vieilledent Updated
Comments
Add a comment