Keep hidden headers (header_layout 100) out of the JSON
Applied on all three render paths: stdWrap.if rule on lib.contentElementWithHeader (before the plugin copies), the same rule in the container element definitions, and a HiddenHeaderProcessor behind the nb content-blocks data processor. headerLayout itself stays in the payload so the front end can tell why the header is empty.
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Evomedien\Vitec\DataProcessing;
|
||||||
|
|
||||||
|
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||||
|
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* header_layout 100 = "Hidden": blank the header fields in the content-blocks
|
||||||
|
* JSON (`data`, produced by nb-content-blocks-json in step 10 of
|
||||||
|
* lib.contentBlock). The layout value itself stays in the payload so the
|
||||||
|
* front end can still tell why the header is empty. Counterpart of the
|
||||||
|
* stdWrap.if rule on lib.contentElementWithHeader / the container elements
|
||||||
|
* (see Sets/Vitecset/setup.typoscript, decision 2026-09-04).
|
||||||
|
*/
|
||||||
|
final class HiddenHeaderProcessor implements DataProcessorInterface
|
||||||
|
{
|
||||||
|
public function process(
|
||||||
|
ContentObjectRenderer $cObj,
|
||||||
|
array $contentObjectConfiguration,
|
||||||
|
array $processorConfiguration,
|
||||||
|
array $processedData
|
||||||
|
): array {
|
||||||
|
$data = $processedData['data'] ?? null;
|
||||||
|
if (is_array($data) && (int)($data['header_layout'] ?? 0) === 100) {
|
||||||
|
foreach (['header', 'subheader', 'header_link'] as $key) {
|
||||||
|
if (isset($data[$key]) && $data[$key] !== '') {
|
||||||
|
$data[$key] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$processedData['data'] = $data;
|
||||||
|
}
|
||||||
|
return $processedData;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,34 @@ config {
|
|||||||
|
|
||||||
@import 'EXT:headless/Configuration/TypoScript/ContentElement/*.typoscript'
|
@import 'EXT:headless/Configuration/TypoScript/ContentElement/*.typoscript'
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
# header_layout 100 = "Hidden" (decision 2026-09-04): such headers stay OUT of
|
||||||
|
# the JSON - header, subheader and headerLink render empty. headerLayout (100)
|
||||||
|
# stays in the payload so the front end could still tell why. Placed BEFORE
|
||||||
|
# the `< lib.contentElementWithHeader` copies below, which snapshot this lib.
|
||||||
|
# The content-blocks `data` path gets the same rule via HiddenHeaderProcessor.
|
||||||
|
# =============================================================================
|
||||||
|
|
||||||
|
lib.contentElementWithHeader.fields.content.fields {
|
||||||
|
header.stdWrap.if {
|
||||||
|
value = 100
|
||||||
|
equals.field = header_layout
|
||||||
|
negate = 1
|
||||||
|
}
|
||||||
|
subheader.stdWrap.if {
|
||||||
|
value = 100
|
||||||
|
equals.field = header_layout
|
||||||
|
negate = 1
|
||||||
|
}
|
||||||
|
headerLink.stdWrap.if {
|
||||||
|
value = 100
|
||||||
|
equals.field = header_layout
|
||||||
|
negate = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lib.contentBlock.fields.data.dataProcessing.20 = Evomedien\Vitec\DataProcessing\HiddenHeaderProcessor
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Headless list-plugin JSON renderers (TYPO3 v14: each plugin is its own CType)
|
# Headless list-plugin JSON renderers (TYPO3 v14: each plugin is its own CType)
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -72,10 +72,22 @@ tt_content.vitec_cols_50_50 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# header_layout 100 = "Hidden": header, subheader and headerLink stay
|
||||||
|
# out of the JSON (same rule as lib.contentElementWithHeader).
|
||||||
header = TEXT
|
header = TEXT
|
||||||
header.field = header
|
header.field = header
|
||||||
|
header.stdWrap.if {
|
||||||
|
value = 100
|
||||||
|
equals.field = header_layout
|
||||||
|
negate = 1
|
||||||
|
}
|
||||||
subheader = TEXT
|
subheader = TEXT
|
||||||
subheader.field = subheader
|
subheader.field = subheader
|
||||||
|
subheader.stdWrap.if {
|
||||||
|
value = 100
|
||||||
|
equals.field = header_layout
|
||||||
|
negate = 1
|
||||||
|
}
|
||||||
headerLayout = INT
|
headerLayout = INT
|
||||||
headerLayout.field = header_layout
|
headerLayout.field = header_layout
|
||||||
headerPosition = TEXT
|
headerPosition = TEXT
|
||||||
@@ -87,6 +99,11 @@ tt_content.vitec_cols_50_50 {
|
|||||||
parameter.field = header_link
|
parameter.field = header_link
|
||||||
returnLast = result
|
returnLast = result
|
||||||
}
|
}
|
||||||
|
stdWrap.if {
|
||||||
|
value = 100
|
||||||
|
equals.field = header_layout
|
||||||
|
negate = 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tx_vitec_bg_variant = TEXT
|
tx_vitec_bg_variant = TEXT
|
||||||
tx_vitec_bg_variant.field = tx_vitec_bg_variant
|
tx_vitec_bg_variant.field = tx_vitec_bg_variant
|
||||||
|
|||||||
Reference in New Issue
Block a user