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:
1 parent
5499ca54af
commit
5aad13e635
3 files changed
+82
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user