PAGEVIEW
New in version 13.1
The content object PAGEVIEW can be used in stead of FLUIDTEMPLATE to configure the HTML body of a page using Fluid templates.
This content object has very specific conventions and defaults, that requires (and allows) less configuration as compared to using FLUIDTEMPLATE.
The benefit is that following these conventions means less boilerplate code to maintain.
If you follow these conventions, a few directories and files must follow the structure outlined below.
Tip
Chapters The TYPO3 Fluid version
and Display the content elements on your page
of the Site Package Tutorial give practical examples on how to use
the PAGEVIEW
object.
Table of contents
Example: Display a page with Fluid templates
Default variables in Fluid templates
The following variables are available by default in the Fluid template.
Additional variables can be defined with property variables.
language
-
- Type
\TYPO3\
CMS\ Core\ Site\ Entity\ Site Language - Example
- Example: Display the site title in the current language
The current
Site
object, see also the SiteLanguage object.Language
page
-
- Type
\TYPO3\
CMS\ Frontend\ Page\ Page Information - Example
- Example: Display the title and abstract of the current page
The current
Page
as object. See also Frontend page information.Information
settings
-
- Type
- array
- Example
- Example: Use TypoScript constant in a Fluid template
site
-
The current
Site
object. See also the Site object.
Examples for using default variables
Example: Display the site title in the current language
Example: Display the title and abstract of the current page
Example: Use TypoScript constant in a Fluid template
Let us assume, the current page loads the following TypoScript constants:
Example: Link to the root page of the current site
Properties
cache
-
- Type
- cache
See cache function description for details.
dataProcessing.[key]
-
- Type
- path with stdWrap
- Example
- Example: Display a main menu and a breadcrumb on the page
Add one or multiple data processors. The sub-property
options
can be used to pass parameters to the processor class.It is recommended to use the PageContentFetchingProcessor to fetch the content elements from the page, respecting the backend layout.
paths.[priority]
-
- Type
- path with stdWrap
- Example
- Example: Define a path that contains all templates
- Example 2
- Example: Define fallbacks for a template paths
Sets an array of paths for the Fluid templates, usually
EXT:
or a path likemy_ extension/ Resources/ Private/ Page View/ EXT:
.my_ extension/ Resources/ Private/ Page View/ My Page The templates are expected in a subfolder
Pages
.Fluid partials are looked up in a sub-directory called
Partials
, layouts inLayouts
.The name of the used page layout (Backend layout) is resolved automatically.
The paths are evaluated from highest to lowest priority.
variables.[variable_name]
-
Sets variables that should be available in Fluid.
Examples
Example: Define a path that contains all templates
This is a basic definition of a PAGEVIEW
object with only one path to the
templates:
page = PAGE
page.10 = PAGEVIEW
page.10.paths.100 = EXT:my_sitepackage/Resources/Private/PageView/
The content of the folder could look like this:
-
-
-
Default.html
-
WithoutHeader.html
-
-
-
Default.html
-
StartPage.html
-
TwoColumns.html
-
With_sidebar.html
-
-
-
Footer.html
-
Sidebar.html
-
Menu.html
-
-
Note
If the name of the backend layout starts with a lowercase letter, the first letter of the template name is transformed into upper case.
However the template name is not necessarily transferred into CamelCase.
So for backend layout named "with_sidebar", the template file is
then resolved to
EXT:
.
If the backend layout is named "TwoColumns" it is resovled to
EXT:
.
For all these templates
partial
are expected in folder
EXT:
and
layouts in
EXT:
.
Example: Define fallbacks for a template paths
You can use the directories defined in paths.[priority] to define fallback directories for the templates:
page = PAGE
page {
10 = PAGEVIEW
10.paths {
100 = EXT:my_basic_sitepackage/Resources/Private/PageView/
200 = EXT:my_general_sitepackage/Resources/Private/PageView/
300 = EXT:my_special_sitepackage/Resources/Private/PageView/
}
}
The template for a page with a certain backend layout is first searched in
EXT:
then in
EXT:
and last
in EXT:
.
Example: Make additional variables available in the Fluid template
page = PAGE
page {
10 = PAGEVIEW
10 {
paths {
100 = EXT:my_sitepackage/Resources/Private/PageView/
}
variables {
parentPageTitle = TEXT
parentPageTitle.data = levelfield:-1:title
another_variable =< lib.anotherVariable
}
}
}
The following variables are now available in the Fluid template: