User Tools

Site Tools


typo3_sitepackage_contentelements

TYPO3 - Site Package - Content elements

Creating a Site Package

Adding new Content elements to your Site Package

Setup new content element

This will show your new element in the content element wizard

Configuration/PageTS/TSconfig.txt
# Custom Contentelements based on fluid
mod.wizards.newContentElement.wizardItems.common {
  elements {
    myextkey_elementname {
      iconIdentifier = content-image
      title = Give it a nice name
      description = Describe what this element is supposed to do
      tt_content_defValues {
        CType = myextkey_elementname
      }
    }
  }
  show := addToList(myextkey_elementname)
}

Add and modify TCA

Configuration/TCA/Overrides/tt_content.php
// Adds the content element to the "Type" dropdown
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
    array(
        'Name in dropdown',
        'myextkey_elementname',
        'EXT:core/Resources/Public/Icons/T3Icons/content/content-image.svg'
    ),
    'CType',
    'myextkey'
);
 
// Add a custom palette
$GLOBALS['TCA']['tt_content']['types']['general_modified'] = [
    'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.headers',
    'showitem' => 'header;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:header_formlabel'
];
 
// Configure the default backend fields for the content element
$GLOBALS['TCA']['tt_content']['types']['myextkey_elementname'] = array(
    'showitem' => '
      --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
         --palette--;;general_modified,
         --palette--;;headers,
      --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.images,image,
      --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
         --palette--;;language,
      --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
         --palette--;;hidden,
         --palette--;;access,
   ',
    'columnsOverrides' => [
        'bodytext' => [
            'config' => [
                'enableRichtext' => true,
                'richtextConfiguration' => 'default'
            ]
        ]
    ]
);

Add a template path

lib.contentElement {
   templateRootPaths {
      200 = EXT:myextkey/Resources/Private/Templates/
   }
}

Configure template

# Add template path for your extension
lib.contentElement {
  templateRootPaths {
    200 = EXT:myextkey/Resources/Private/Templates/
  }
}
 
# Load defaults and define Template
tt_content {
  myextkey_elementname =< lib.contentElement
  myextkey_elementname {
    templateName = NameOfYourTemplate
  }
}

Depending on which contentelement this is based on you can simply load.

For example this element should be based on image:

tt_content {
  myextkey_elementname =< tt_content.image
  myextkey_elementname {
    templateName = NameOfYourTemplate
  }
}

You'll find all available CEs in typo3/sysext/fluid_styled_content/Configuration/TypoScript/ContentElement/.

Config field for certain cType

$GLOBALS['TCA']['tt_content']['types']['CTYPE_NAME']['columnsOverrides']['image']['config']['maxitems'] = 3;
$GLOBALS['TCA']['tt_content']['types']['CTYPE_NAME']['columnsOverrides']['image']['config']['minitems'] = 3;
typo3_sitepackage_contentelements.txt · Last modified: 2018/09/28 09:53 by admin