Content and Location view providers
View\Manager & View\Provider
The role of the (eZ\Publish\Core\MVC\Symfony\)View\Manager is to select the right template for displaying a given content item or location. It aggregates objects called content and location view providers which respectively implement eZ\Publish\Core\MVC\Symfony\View\Provider\Content and eZ\Publish\Core\MVC\Symfony\View\Provider\Location interfaces.
Each time a content item is to be displayed through the Content\ViewController, the View\Manager iterates over the registered content or location View\Provider objects and calls getView().
Provided View\Provider implementations
| Name | Usage |
|---|---|
| View provider configuration |
Based on application configuration. Formerly known as Template override system. |
| eZ\Publish\Core\MVC\Legacy\View\Provider\Content eZ\Publish\Core\MVC\Legacy\View\Provider\Location |
Forwards view selection to the legacy kernel by running the old content/view module. Pagelayout used is the one configured in exponential_legacy.<scope>.view_default_layout. For more details about the <scope> please refer to the scope configuration documentation. |
Custom View\Provider
Difference between View\Provider\Location and View\Provider\Content
- A View\Provider\Location only deals with Location objects and implements eZ\Publish\Core\MVC\Symfony\View\Provider\Location interface.
- A View\Provider\Content only deals with ContentInfo objects and implements eZ\Publish\Core\MVC\Symfony\View\Provider\Content interface.
When to develop a custom View\Provider\(Location|Content)
- 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
View\Provider 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 View\Provider\(Content|Location) in the View\Manager. The priority range is from -255 to 255 |
Example
Custom View\Provider\Location
Contributors
- Jérôme Vieilledent Commenter
- Dominika Kurek Updated
- Philippe Vincent-Royol Commenter
Comments (2 historical)
Written by readers of the earlier documentation sites, kept as they were.
Comment by Philippe Vincent-Royol, 2012-12-07 14:35
Philippe Vincent-Royol ·
Hello,
Example Custom ContentViewProvider is not working. Path to eZ\Publish\MVC\View\ContentViewProvider is wrong with eZ 5.0 platform
Comment by Jérôme Vieilledent, 2013-01-29 14:41
Jérôme Vieilledent ·
Philippe Vincent-Royol: Fixed, thanks