Setting a default pagelayout for content in eZ Platform
In eZ Publish you could trust that the templating system will route the rendered menu content to be inserted into the pagelayout.tpl. This allowed developers to always be confortable that their global page elements like menus, search, header and footer will be available.
In eZ Platform this is not as clear as you use the Twig template to extend the pagelayout.html.twig file manually. This means that when adding new content types and content you'll need to configure the template manually using views.yml:
ezpublish:
system:
default:
user:
layout: ixCoolEstateBundle:Default:pagelayout.html.twig
content_view:
full:
folder_apartments:
controller: ixCoolEstateBundle:FullView:apartments
template: ixCoolEstateBundle:Default:full/apartments.html.twig
match:
Id\Location: [54]
But to override the pagelayout universally you can also use the parameters.yml (app/config/parameters.yml) to override the base layout for the full view:
# This file is auto-generated during the composer install
parameters:
ezplatform.default_view_templates.content.full: content_fallback.html.twig
Once you have this in place, then you'll have a fallback template which extends the main template and loops all the fields for display using Twig:
{% set page_title = ez_content_name(content) ~ ' | Cool Estate' %}
{% extends "@ixCoolEstate/Default/pagelayout.html.twig" %}
{% block content %}
<h2>{{ ez_content_name(content) }}</h2>
{% for field in content.fieldsByLanguage %}
<h3>{{ field.fieldDefIdentifier }}</h3>
{{ ez_render_field(content, field.fieldDefIdentifier) }}
{% endfor %}
{% endblock %}