.. include:: /Includes.rst.txt
.. _DataProcessingHowTo:
How To
------
This guide outlines the configuration of the `GridChildrenProcessor`, its options, and examples of corresponding templates and partials for rendering grid-based layouts in TYPO3.
Recommended approach vs. legacy path
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The `GridChildrenProcessor` represents the recommended, Fluid-based approach to handling grid layouts in TYPO3, offering significant advantages over the deprecated legacy path built on the ``Gridelements`` plugin. See :ref:`RenderingArchitecture` for how the two relate.
**Legacy path (deprecated, not recommended for new projects):**
The original Grid Elements implementation relied on the `Gridelements->main` userFunc in TypoScript, which processed grid children internally and rendered them using pre-defined TypoScript objects (COA, TEMPLATE). This method required extensive TypoScript configuration for customization and made it difficult to separate content structure from presentation.
**Recommended approach with GridChildrenProcessor:**
The DataProcessor approach leverages TYPO3's ContentObjectRenderer data processing capabilities to:
* Separate data gathering from rendering logic
* Allow full Fluid template control over the grid structure
* Provide specific rendering options per grid layout type
* Enable recursive processing of nested grids with clean template code
* Offer greater flexibility through configuration options like `respectColumns` and `respectRows`
* Integrate seamlessly with other TYPO3 data processors
This approach significantly improves maintainability and template reusability, and follows TYPO3's current best practices for content rendering.
Example Configuration
^^^^^^^^^^^^^^^^^^^^^
Below is an example `GridChildrenProcessor` configuration:
.. code-block:: typoscript
lib.gridelements {
templateName = GridElement
templateName.override.field = tx_gridelements_backend_layout
templateRootPaths {
1 = EXT:gridelements/Resources/Private/Templates/
}
partialRootPaths {
1 = EXT:gridelements/Resources/Private/Partials/
}
dataProcessing {
10 = GridElementsTeam\Gridelements\DataProcessing\GridChildrenProcessor
10 {
default {
as = children
options {
sortingDirection = asc
sortingField = sorting
recursive = 0
resolveFlexFormData = 1
resolveChildFlexFormData = 1
resolveBackendLayout = 1
respectColumns = 1
respectRows = 1
}
}
}
}
}
---
Templates and Partials
^^^^^^^^^^^^^^^^^^^^^^
The templates and partials used with `GridChildrenProcessor` extend TYPO3's grid-based rendering functionality. Samples are provided below for each template and partial used in the configuration.
Those samples are provided by Grid Elements out of the box, but you can of course still create your own templates with fewer conditions, if your layouts are strictly bound to a certain configuration.
Just add those settings to the TypoScript template based on your Grid Elements backend layouts and configure them to your needs.
.. code-block:: typoscript
10 = GridElementsTeam\Gridelements\DataProcessing\GridChildrenProcessor
10 {
default {
[...]
}
myLayout1 { # Custom key for this layout
as = children
options {
sortingField = title # Sort child elements alphabetically by their title
sortingDirection = desc # Change sorting direction to descending
recursive = 0 # Do not pre-fetch a nested container's own children in this pass
resolveFlexFormData = 0 # Keep original FlexForm XML without conversion
resolveBackendLayout = 0 # Disable resolution of backend layouts
respectColumns = 0 # Disable column grouping
respectRows = 0 # Also disable row grouping; respectRows defaults to 1 and row handling requires column handling, so both must be off for a genuinely flat list
}
}
myLayout2 { # Custom key for this layout
as = somethingElse # use a different key to deal with your child elements
options {
recursive = 1 # Pre-fetch one additional level of nested container children in this pass
respectColumns = 1 # Group children by their column value
respectRows = 0 # Skip grouping by rows, e.g. with a single row configuration
}
}
}
``recursive`` only changes how many levels of children this processing
pass pre-fetches in one go. It is not a structural depth limit;
nesting itself is unconditional and unaffected by this option, see
:ref:`Nesting` for the full distinction between structural nesting,
this option, and the Fluid template recursion described below.
**Template: GridElement.html**
""""""""""""""""""""""""""""""
This is the main entry template for rendering the grid layout.
.. code-block:: html