Hallo Tobias, ich habe drei mögliche Varianten für dich:
- Eine passende Extension verwenden z.B. mask oder dce. Das ist die schnellste und einfachste Lösung.
- Content Blocks nutzen, wie bereits vorgeschlagen.
- Wenn du ein eigenes Content Element erstellen möchtest, musst du etwas Code ergänzen und eine zusätzliche Tabelle anlegen:
Card-Element:
Overrides/tt_content.php
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
'tt_content',
'CType',
[
'LLL:EXT:xxx/Resources/Private/Language/locallang.xlf:card_title',
'card',
'content-textpic'
],
'html',
'after'
);
$tca = array(
'types' => array(
'card' => array(
'showitem' => '--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,
card;LLL:EXT:xxx/Resources/Private/Language/locallang.xlf:card_content_title,
'
)
),
'columns' => array(
'card' => array(
'config' => array(
'type' => 'inline',
'foreign_table' => 'tx_xxx_domain_model_card',
'foreign_field' => 'tt_content_uid',
),
),
),
);
$GLOBALS['TCA']['tt_content'] = array_replace_recursive($GLOBALS['TCA']['tt_content'], $tca);
TCA/tx_xxx_domain_model_card.php:
'columns' => array(
...
'header' => array(
'exclude' => 0,
'label' => 'Heading',
'config' => array(
'type' => 'input',
'size' => 50,
'eval' => 'trim',
'required' => true
),
),
)
...
Und auch SQL ext_tables.sql erweitern:
#
# Table structure for table 'tx_xxx_domain_model_card'
#
CREATE TABLE tx_xxx_domain_model_card (
...
tt_content_uid int(11) DEFAULT '0' NOT NULL,
header varchar(255) DEFAULT '' NOT NULL,
...
);
Danach brauchst du MVC-Datenmodel mit Getters und Setters mit Repository mit passende Funktionen in Classes/Domain...
...
class Card extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* ttContentUid
*
* @var integer
*/
protected $ttContentUid = '';
/**
* Heading
*
* @var string
*/
protected $header = '';
...
/**
* @param int $ttContentUid
* @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
*/
public function findByTtContentUid($ttContentUid) {
$query = $this->createQuery();
$query->getQuerySettings()->setRespectStoragePage(FALSE);
$query->setOrderings(array(
'sorting' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING
)
);
$query->matching(
$query->equals('tt_content_uid', $ttContentUid)
);
return $query->execute();
}
Und noch ein Processor dafür:
/**
* Process data for the content element
*
* @param ContentObjectRenderer $cObj The data of the content element or page
* @param array $contentObjectConfiguration The configuration of Content Object
* @param array $processorConfiguration The configuration of this processor
* @param array $processedData Key/value store of processed data (e.g. to be passed to a Fluid View)
* @return array the processed data as key/value store
*/
public function process(
ContentObjectRenderer $cObj,
array $contentObjectConfiguration,
array $processorConfiguration,
array $processedData
)
{
$cardRepository = GeneralUtility::makeInstance(CardRepository::class);
$processedData['cards'] = $cardRepository->findByTtContentUid($processedData['data']['uid']);
return $processedData;
}
Auch ein bisschen Typoscript Magie :)
tt_content.card = FLUIDTEMPLATE
tt_content.card {
file = EXT:xxx/Resources/Private/Templates/Card.html
dataProcessing {
20 = XXX\XXX\DataProcessing\CardProcessor
}
}