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.

$GLOBALS['TCA']['tt_content']['types']['ServiceCE'] = [
   'showitem' => '
            header; Header,

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



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.