netzbewegung / nb-headless-content-blocks
Connects together EXT:headless and EXT:content_block
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 1
Open Issues: 0
Type:typo3-cms-extension
Requires
- friendsoftypo3/content-blocks: >=1.0
- friendsoftypo3/headless: ^4.5
- typo3/cms-core: ^13.4
This package is auto-updated.
Last update: 2025-03-18 17:30:55 UTC
README
Connects together EXT:headless (friendsoftypo3/headless) and EXT:content_blocks (friendsoftypo3/content-blocks)
TYPO3 Installation
Install extension using composer
composer require netzbewegung/nb_headless_content_blocks
and then, include Site Set "Headless Content Blocks", and you are ready to go.
Custom Configuration per Content Block Type
Create headless.php inside each Content Block.
your_extension/ContentBlocks/ContentElements/your-content-block-element/headless.php
<?php
use TYPO3\CMS\Fluid\ViewHelpers\Uri\ImageViewHelper;
$generateThumbnail = function (array $arguments): string {
if (array_key_exists('absolute', $arguments) === false) {
$arguments['absolute'] = true;
}
$imageViewHelper = new ImageViewHelper();
foreach ($imageViewHelper->prepareArguments() as $argumentKey => $argumentDefinition) {
if (array_key_exists($argumentKey, $arguments) === false) {
$arguments[$argumentKey] = $argumentDefinition->getDefaultValue();
}
}
$imageViewHelper->setArguments($arguments);
return $imageViewHelper->initializeArgumentsAndRender();
};
foreach ($data->items ?? [] as $itemKey => $item) {
if ($item->image) {
$image = $item->image;
$data->items[$itemKey]->image->thumbnails = [
'mobile' => $generateThumbnail(['src' => $image->id, 'treatIdAsReference' => true, 'width' => 320]),
'desktop' => $generateThumbnail(['src' => $image->id, 'treatIdAsReference' => true, 'width' => 800]),
];
}
}
return $data;