Breaking: #92434 - Use Record API in Page Module Preview Rendering
See forge#92434
Description
The Page Module preview rendering has been refactored to use the Record API
internally instead of accessing raw database arrays. This affects both custom
preview renderers that extend
Standard and
Fluid-based preview templates.
The method signature has changed for
\TYPO3\:
Standardnow expects aContent Preview Renderer->link Edit Content () Recordobject as the secondInterface $recordparameter instead of an array
The
\TYPO3\ has
also been updated:
Pagenow returns aContent Preview Rendering Event->get Record () Recordobject instead of an arrayInterface Pagenow expects aContent Preview Rendering Event->set Record () Recordobject instead of an arrayInterface
Additionally, the @internal class
\TYPO3\ has been
updated to work with Record objects:
Gridrequires aColumn Item () Recordobject as the thirdInterface $recordparameter instead of an arrayGridnow returns aColumn Item->get Record () Recordobject instead of an arrayInterface Gridnow expects aColumn Item->set Record () Recordobject instead of an arrayInterface - A new method
Gridhas been added to access the raw database array if neededColumn Item->get Row ()
For Fluid-based content element previews, the template variables have changed.in
Previously, all record fields were passed as individual variables to the Fluid
template. Now, only a single
{record} variable is passed, which is a
Record object providing access to all record data through
the Record API.
Using the
{pi_ in Fluid-based content element
previews does no longer work. The resolved flex form can be directly
accessed on the
Record object, e.g. via
{record.. The value is a
Flex
object. This object properly groups the fields by their sheets.
Impact
Extensions that extend
Standard and override the
link method will need to update their method signature.
Extensions that access
Grid expecting an array will
need to update their code to work with
Record objects.
Extensions using event listeners for
Page that
access the record via
get expecting an array will need to update
their code to work with
Record objects.
Custom Fluid templates for content element preview rendering must be updated to
use the
{record} variable instead of accessing individual field variables.
Affected Installations
All installations with extensions that:
- Extend
Standardand call or override theContent Preview Renderer linkmethodEdit Content () - Instantiate
Gridor callColumn Item Grid/Column Item->get Record () GridColumn Item->set Record () - Event listeners for
PageContent Preview Rendering Event - Custom Fluid templates for content element preview rendering via PageTSconfig
mod.web_ layout. tt_ content. preview. [record Type]
Migration
For custom preview renderers extending
Standard:
Update the method signature of
link to accept a
Record object:
protected function linkEditContent(string $linkText, array $row, string $table = 'tt_content'): string
{
$uid = (int)$row['uid'];
$pid = (int)$row['pid'];
// ...
}
protected function linkEditContent(string $linkText, RecordInterface $record): string
{
$uid = $record->getUid();
$pid = $record->getPid();
$table = $record->getMainType();
// ...
}
For code working with
Grid:
$row = $columnItem->getRecord();
$uid = (int)$row['uid'];
$title = $row['header'];
$record = $columnItem->getRecord();
$uid = $record->getUid();
$title = $record->has('header') ? $record->get('header') : '';
// Or if raw array access is needed:
$row = $columnItem->getRow();
$uid = (int)$row['uid'];
For custom Fluid templates used for content element preview rendering:
<h2>{header}</h2>
<p>{bodytext}</p>
<f:if condition="{image}">
<p>Image UID: {image}</p>
</f:if>
<h2>{record.header}</h2>
<p>{record.bodytext}</p>
<f:if condition="{record.image}">
<p>Image UID: {record.image.uid}</p>
</f:if>
For flex form value rendering, there are two options:
<h2>{header}</h2>
<p>{bodytext}</p>
<small>{pi_flexform_transformed.settings.welcome_header}</small>
<f:if condition="{image}">
<p>Image UID: {image}</p>
</f:if>
<f:variable name="path" value="s_messages/settings" />
<small>{record.pi_flexform.{path}.welcome_header}</small>
// or
<small>{record.pi_flexform.sheets.s_messages.settings.welcome_header}</small>