Feature: #90348 - Fluid-based replacement for PageLayoutView

See forge#90348

Description

A completely rewritten replacement for PageLayoutView has been added. This replacement allows third parties to override and extend any part of the "page" module's output by overriding Fluid templates.

Although it is visually identical to the old PageLayoutView's output, the new alternative has a number of benefits:

  • The grid defined in a BackendLayout is now represented as objects which are assigned to Fluid templates and can be iterated over to render rows, columns and records.

  • Custom BackendLayout implementations can now manipulate every part of the configuration that determines how the page module is rendered - or completely replace the logic that draws the "columns" and "languages" views of the page BE module.

  • Custom BackendLayout implementations can also provide custom classes for LanguageColumn, Grid, GridRow, GridColumn and GridColumnItem instances that are assigned to and used by Fluid templates to render the page layout.

  • Headers, footers and previews for content types can be created in Fluid in a way that groups each of these component templates by the content type (CType) value of content records.

  • Any part of the page layout can now be rendered elsewhere by creating instances of any of the "grid" objects and assigning them to Fluid templates.

  • The "grid" structure of BackendLayouts can be manipulated as objects, adding and removing rows and columns on-the-fly.

The new Fluid-based implementation is enabled by the global setting $GLOBALS['TYPO3_CONF_VARS']['SYS']['features']['fluidBasedPageModule'] which can be changed from the install tool or from extensions. The setting is enabled by default, meaning that the Fluid-based implementation is used as default method in this and future TYPO3 versions. The feature flag can be managed either by setting it through code (for example, in ext_localconf.php of an extension) or you can set it through the "Settings" admin module's' "Feature Toggles" view.

New Fluid templates:

  • EXT:backend/Resources/Private/Templates/PageLayout/PageLayout.html

  • EXT:backend/Resources/Private/Templates/PageLayout/UnusedRecords.html

  • EXT:backend/Resources/Private/Partials/PageLayout/Grid.html

  • EXT:backend/Resources/Private/Partials/PageLayout/Grid/Column.html

  • EXT:backend/Resources/Private/Partials/PageLayout/Record.html

  • EXT:backend/Resources/Private/Partials/PageLayout/Record/Header.html

  • EXT:backend/Resources/Private/Partials/PageLayout/Record/Footer.html

These Fluid templates can be overridden or extended by TS, depending on which type or types of templates you wish to override:

  • module.tx_backend.view.templateRootPaths.100 = EXT:myext/Resources/Private/Templates/

  • module.tx_backend.view.partialRootPaths.100 = EXT:myext/Resources/Private/Partials/

In addition, custom header/footer/preview templates can be added by extending the partialRootPaths and placing for example a template file in:

  • EXT:myext/Resources/Private/Partials/PageLayout/Record/my_contenttype/Header

  • EXT:myext/Resources/Private/Partials/PageLayout/Record/my_contenttype/Footer

  • EXT:myext/Resources/Private/Partials/PageLayout/Record/my_contenttype/Preview

If no such templates exist the default partials (listed above) are used. Note that the folder name my_contenttype should use the CType value associated with the content type for which you wish to provide a custom header, footer or preview template.

Within these last three types of templates the following variables are available:

  • {item} which represents a single record.

  • {backendLayout} which represents the BackendLayout instance that defined the grid which was rendered.

  • {grid} which represents the Grid instance that was produced by the BackendLayout (also accessible through {backendLayout.grid}, provided as extracted variable for easier and more performance-efficient access)

Properties on {item} include:

  • {item.record} (the database row of the content element)

  • {item.column} (the GridColumn instance within which the item resides)

  • {item.delible}

  • {item.translations} (bool, whether or not the item is translated)

  • {item.dragAndDropAllowed} (bool, whether or not the item can be dragged and dropped)

  • {item.footerInfo} (array)

Properties on {backendLayout} include:

  • {backendLayout.configurationArray} (array, the low level definition of rows/columns within the BackendLayout - array form of the pageTSconfig that defines the grid)

  • {backendLayout.iconPath}

  • {backendLayout.description}

  • {backendLayout.identifier}

  • {backendLayout.title}

  • {backendLayout.drawingConfiguration} (the instance of DrawingConfiguration which holds properties like active language, site languages and TCA labels for content types and content record fields)

  • {backendLayout.grid} (the instance of the Grid that represents the backend layout rows/columns as PHP objects)

Impact

  • A new feature setting $GLOBALS['TYPO3_CONF_VARS']['SYS']['features']['fluidBasedPageModule'] has been introduced, enabled by default, which allows switching to the legacy PageLayoutView.

  • By default, a new set of objects and extended methods on BackendLayout now provide a completely Fluid-based implementation of the "page" BE module.