PAGEVIEW¶
New in version 13.1
This API is considered experimental until TYPO3 v13 LTS. It will be further adapted to be used for further rendering of custom Content Elements and Content Blocks.
The content object EXTBASEPLUGIN
allows to render
Extbase plugins.
The new PAGEVIEW
content object has very specific conventions and
defaults, that requires (and allows) less configuration. 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.
Table of contents
Example: Display a page with Fluid templates¶
page = PAGE
page {
10 = PAGEVIEW
10 {
paths {
100 = EXT:my_sitepackage/Resources/Private/Templates/
}
variables {
parentPageTitle = TEXT
parentPageTitle.data = levelfield:-1:title
}
dataProcessing {
10 = menu
10.as = mainMenu
}
}
}
Default variables in Fluid templates¶
The following variables are available by default in the Fluid template.
Additional variables can be defined with property variables.
Name | Type |
---|---|
\TYPO3\CMS\Core\Site\Entity\SiteLanguage |
|
TYPO3\CMS\Frontend\Page\PageInformation |
|
array | |
\TYPO3\CMS\Core\Site\Entity\Site |
-
language
¶ -
- Type
\TYPO3\CMS\Core\Site\Entity\SiteLanguage
- Example
- Example: Display the site title in the current language
The current
SiteLanguage
object, see also the SiteLanguage object.
-
page
¶ -
- Type
TYPO3\CMS\Frontend\Page\PageInformation
- Example
- Example: Display the title and abstract of the current page
The current
PageInformation
as object. See also Frontend page information.
-
settings
¶ -
- Type
- array
- Example
- Example: Use TypoScript constant in a Fluid template
The variable
{settings}
contains all TypoScript constants that are set on the current page.
-
site
¶ -
- Type
\TYPO3\CMS\Core\Site\Entity\Site
- Example
- Example: Link to the root page of the current site
The current
Site
object. See also the Site object.
Examples for using default variables¶
Example: Display the site title in the current language¶
<f:layout name="Default" />
<f:section name="Main">
<main role="main">
<p>The site title in the current template is: {language.websiteTitle}</p>
</main>
</f:section>
Example: Display the title and abstract of the current page¶
<f:layout name="Default" />
<f:section name="Main">
<main role="main">
<p>The title of the page with id {page.id} is: {page.pageRecord.title}. It has the
following abstract:</p>
<p>{page.pageRecord.abstract}</p>
</main>
</f:section>
Example: Use TypoScript constant in a Fluid template¶
Let us assume, the current page loads the following TypoScript constants:
page {
uids {
dataPrivacy = 42
contact = 85
imprint = 86
}
}
<f:layout name="Default" />
<f:section name="Main">
<main role="main">
<p>...</p>
</main>
<footer>
See also our <f:page pageUid="{settings.page.uid.dataPrivacy}">data privacy policy</f:page>
</footer>
</f:section>
Example: Link to the root page of the current site¶
<f:layout name="Default" />
<f:section name="Main">
<main role="main">
<p>Go to the root page: <f:link.page pageUid="{page.rootPageId}">Home</f:link.page></p>
<p>...</p>
</main>
</f:section>
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.
-
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:my_extension/Resources/Private/Templates/
or a folder below that path likeEXT:my_extension/Resources/Private/Templates/MyPages
.The templates are expected in a subfolder
Pages
orpages
.Fluid partials are looked up in a sub-directory called
Partials
orpartials
, layouts inLayouts
orlayouts
.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/Templates/
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:my_sitepackage/Resources/Private/Templates/Pages/With_sidebar.html
.
If the backend layout is named "TwoColumns" it is resovled to
EXT:my_sitepackage/Resources/Private/Templates/Pages/TwoColumns.html
.
For all these templates
partials
are expected in folder
EXT:my_sitepackage/Resources/Private/Templates/Pages/Partials
and
layouts in
EXT:my_sitepackage/Resources/Private/Templates/Pages/Layouts
.
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/Templates/
200 = EXT:my_general_sitepackage/Resources/Private/Templates/
300 = EXT:my_special_sitepackage/Resources/Private/Templates/
}
}
The template for a page with a certain backend layout is first searched in
EXT:my_special_sitepackage/Resources/Private/Templates/Pages/
then in
EXT:my_general_sitepackage/Resources/Private/Templates/Pages/
and last
in EXT:my_basic_sitepackage/Resources/Private/Templates/Pages/
.
Example: Make additional variables available in the Fluid template¶
page = PAGE
page {
10 = PAGEVIEW
10 {
paths {
100 = EXT:my_sitepackage/Resources/Private/Templates/
}
variables {
parentPageTitle = TEXT
parentPageTitle.data = levelfield:-1:title
another_variable =< lib.anotherVariable
}
}
}
The following variables are now available in the Fluid template:
<f:layout name="Default" />
<f:section name="Main">
<f:render partial="Navigation/MainNavigation.html" arguments="{_all}"/>
<main role="main">
<p>The current parent page has the title {parentPageTitle}</p>
<p>Another variable is {another_variable}</p>
</main>
</f:section>