User Tools

Site Tools


typo3_sitepackage_contentelements

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
typo3_sitepackage_contentelements [2015/10/07 10:56] – [Setup new content element] admintypo3_sitepackage_contentelements [2018/09/28 07:53] (current) admin
Line 5: Line 5:
 Why using a Site Package: http://de.slideshare.net/benjaminkott/typo3-the-anatomy-of-sitepackages Why using a Site Package: http://de.slideshare.net/benjaminkott/typo3-the-anatomy-of-sitepackages
  
-Code by Example: https://github.com/benjaminkott/example_package+See: https://docs.typo3.org/typo3cms/extensions/fluid_styled_content/latest/AddingYourOwnContentElements/
  
 ===== Adding new Content elements to your Site Package ===== ===== Adding new Content elements to your Site Package =====
- 
-Manual to get started: 
-http://t3-developer.com/typo3-installation/einrichtung/typo3-erweiteren/eigene-contentelemente-in-typo3-erstellen/ 
  
 ==== Setup new content element ==== ==== Setup new content element ====
  
-<code typoscript Configuration/TypoScript/TSconfig/Page/TSconfig.txt> +This will show your new element in the content element wizard 
-#### ELEMENT IN WIZARD MIT AUFNEHMEN + 
-mod.wizards.newContentElement.wizardItems +<code typoscript Configuration/PageTS/TSconfig.txt> 
-    common { +Custom Contentelements based on fluid 
-       elements {     +mod.wizards.newContentElement.wizardItems.common { 
-        slider +  elements { 
-            title = SLIDER ODER???? +    myextkey_elementname 
-            description = Macht nen total fetzigen Slider +      iconIdentifier = content-image 
-            icon = gfx/c_wiz/user_defined.gif +      title = Give it a nice name 
-            tt_content_defValues { +      description = Describe what this element is supposed to do 
-                CType = slider +      tt_content_defValues { 
-            } +        CType = myextkey_elementname 
-        } +      }
-       } +
-    show := addToList(slider)+
     }     }
 +  }
 +  show := addToList(myextkey_elementname)
 } }
-</code> 
  
-Dont forget to include it: 
-<code typoscript> 
-<INCLUDE_TYPOSCRIPT: source="FILE:EXT:t1_distribution/Configuration/TypoScript/TSconfig/Page/TSconfig.txt"> 
 </code> </code>
  
 +==== Add and modify TCA ====
  
-<code php ext_tables.php> 
  
-# FELDER VON TEXTPIC ÜBERNEHMEN ... +<code php Configuration/TCA/Overrides/tt_content.php>
-$TCA['tt_content']['types']['slider']['showitem'] = '--palette--;LLL:EXT:hello_world/Resources/Private/Language/locallang_mod.xlf:content_element.hello_world.general;general, --palette--;LLL:EXT:hello_world/Resources/Private/Language/locallang_mod.xlf:content_element.hello_world.header;header';+
  
- +// Adds the content element to the "Type" dropdown 
-$backupCTypeItems = $GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items']; +\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
-$GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] = array(+
     array(     array(
-        'Slider', +        'Name in dropdown', 
-        '--div--'+        'myextkey_elementname', 
 +        'EXT:core/Resources/Public/Icons/T3Icons/content/content-image.svg'
     ),     ),
-    array( +    'CType', 
-        'Slider', +    'myextkey'
-        'slider'+
-        'i/tt_content_header.gif' +
-    )+
 ); );
-foreach($backupCTypeItems as $key => $value){ + 
-    $GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'][= $value;+// 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' 
 +            ] 
 +        ] 
 +    ] 
 +); 
 + 
 +</code> 
 + 
 +==== Add a template path ==== 
 + 
 +<code> 
 +lib.contentElement { 
 +   templateRootPaths { 
 +      200 = EXT:myextkey/Resources/Private/Templates/ 
 +   }
 } }
 </code> </code>
 +
 +==== Configure template ====
 +
 +<code typoscript>
 +# 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
 +  }
 +}
 +</code>
 +
 +Depending on which contentelement this is based on you can simply load.
 +
 +For example this element should be based on ''image'':
 +
 +<code typoscript>
 +tt_content {
 +  myextkey_elementname =< tt_content.image
 +  myextkey_elementname {
 +    templateName = NameOfYourTemplate
 +  }
 +}
 +</code>
 +
 +You'll find all available CEs in ''typo3/sysext/fluid_styled_content/Configuration/TypoScript/ContentElement/''.
 +
 +==== Config field for certain cType ====
 +
 +<code php>
 +$GLOBALS['TCA']['tt_content']['types']['CTYPE_NAME']['columnsOverrides']['image']['config']['maxitems'] = 3;
 +$GLOBALS['TCA']['tt_content']['types']['CTYPE_NAME']['columnsOverrides']['image']['config']['minitems'] = 3;
 +</code>
 +
typo3_sitepackage_contentelements.1444215410.txt.gz · Last modified: 2015/10/07 10:56 by admin