Types
Introduction
Page types
are allow you to define custom fields and layout for pages of this type.
Fields
Below is a list of fields
in the types
stream. Fields are accessed as attributes:
$type->name;
Same goes for decorated instances in Twig:
{{ type.name }}
Fields
Key | Type | Description |
---|---|---|
name |
text |
The type name. |
description |
textarea |
The type description. |
slug |
slug |
The slug used for API and database table. |
handler |
addon |
The page handler extension to use. |
theme_layout |
select |
The default theme layout for pages of this type. |
layout |
editor |
The layout of the custom page fields. |
Theme Layouts
The type's theme layout will define the defualt theme layout to wrap the page's content.
Theme layouts generally specify the top level structural layout of your website. Perhaps a layout for your home page specifically, one for two column pages, and perhaps one custom HTML pages.
Accessing Active Pages
You can access the active page in theme layouts if needed by using the template
super variable.
{{ template.page.title }}
A more realistic example might look like this:
{% if template.page.banner_image.id %}
<div id="banner" style="background-image: url({{ template.page.banner_image.path }});">
...
</div>
{% endif %}
Page Layouts
The type's page layout is wrapped by the theme layout.
The primary goal of the page layout is to display the page's custom field values.
Defining Page Layouts
When defining the page layout the page
is available to access field values.
In the simple example below content
is the field slug of the WYSIWYG field assigned to this page's type.
<h1>{{ page.title }}</1h>
{{ page.content.render|raw }}
A more powerful example using our Grid field type with the field slug content
might look like this:
{% for section in page.content %}
<div class="section {{ section.type }}-section-type">
{% include "theme::sections/" ~ section.type %}
</div>
{% endfor %}
The above example will let you define well designed and controlled content section that allow the user to easily build structured stacks of content.