Ad

New Custom Content Element On Typo3 With A Select Option

- 1 answer

I want to create a content element where the editor can chose an icon to display on the frontend.

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
   'tt_content',
   'CType',
    [
        'LLL:EXT:your_extension_key/Resources/Private/Language/Tca.xlf:yourextensionkey_newcontentelement',
        'ServiceCE',
        'example-registration',
    ],
    'textmedia',
    'after'
);
$GLOBALS['TCA']['tt_content']['types']['ServiceCE'] = [
   'showitem' => '
      --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
         --palette--;;general,
            header; Header,
            bodytext;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:bodytext_formlabel,
   ',
];

Here I'm creating the layout on the back-end to insert the content, with just a header and a bodytext.

Ad

Answer

There would be a lot of possible solutions:

dependent whether the icon should be assigned to pages or content elements work with the table pages or tt_content

  1. your extension will provied the list of icons:
    add an additional field with a select list for the icons to the records. put it into TCA (Configuration/TCA/Override/<table>.php). Make sure the value is the icon-name, so you do not need additional replacements in FLUID. Add the rendering to the FLUID template where it belongs. As it should be available everywhere the Layout-templates would be a good place.

  2. use sys_categories: use the build in categories for providing icons to any record.
    create some categories with either the icon as category image or use another field as the icon name. (You even could add another field especially for the icon name.)
    For the rendering of pages or tt_content add a data processor to get the assigned sys_category-records of the data record and then render the first/all icon(s) of the record in the Layout-templates.

Ad
source: stackoverflow.com
Ad