Best flexform based content elements since 2012. With TCA mapping feature, simple backend view and much more
features which makes it super easy to create own content element types.
Keywords
TYPO3 CMS, DCE, FCE, Content elements, Dynamic Content Elements
With this extension, you can easily create new dynamic content elements.
In opposite to native content elements (fluid_styled_content), DCEs are based on FlexForms.
FlexForms allows you to define dynamic content structures, without the need to extend tt_content database table.
Note
tt_content is the database table, which stores all content elements.
Note
FlexForms allows defining dynamic forms, which get stored as XML in tt_content column "pi_flexform".
This makes it hard to perform queries on fields defined in your DCE content elements, unless you've enabled
TCA mapping.
Content Elements in TYPO3
TYPO3 itself provides a bunch of content elements (CE) with EXT:fluid_styled_content.
You can easily hide unused elements or fields, but it is not that easy to build new content element types (CTypes).
If you want to extend content elements in TYPO3 natively, you need to write an extension and provide the custom TCA
configuration on your own. Also, you need to provide a hook or implement a preview renderer, if you want to define
the look-like of your content element in the backend, too.
Goals of DCE
Make it easy to create new custom content elements
With as many configurable fields as you want
Flexible and comfortable templating for each CE (using Fluid)
A lower learning curve for editors (using customized content elements)
and for integrators as well, who start with TYPO3 CMS
First, you need to login to TYPO3 backend with administrator privileges. Those are required to create or edit DCEs.
Content elements made by DCE, can be also used with regular editor privileges.
You'll find DCE under "Admin Tools" in the main menu. It shows you a list of all DCEs existing in the database:
Note
DCEs are stored on root level (pid=0). You can also access DCEs in list view.
DCE fields are not displayed directly.
Create your first DCE
Click the button "Create new DCE" and enter the title of your new dynamic content element. For example: "Teaser".
Also, we set the identifier to "teaser". Later this will be prefixed with "dce_" and used as CType of this
new content element.
Now, create a new field, keep the default type "Element" and enter "Title" as field title.
Set variable to "title".
Attention
Variable names for DCE fields have to be written in lowerCamelCase!
As configuration we choose the option "Simple input field" from the dropdown above the code editor.
It pastes a sample configuration with commonly used settings. You should get this output:
Now, add another new field with the title "Description" and "description" as the variable name. As configuration we use
"RTE" from the dropdown box.
Next, create the last field with the title "Images" and the variable name "images". As configuration we use
"File Abstraction Layer (recommended)" of the type "Inline". The configuration of a FAL media field is pretty complex,
but you also find options like minimum and maximum of images, or which file types should be allowed.
Save the changes. You should see the structure of your first DCE:
Now, when you clear the system caches, you can already use the content element on your pages:
Frontend Templating
Let's return to your Teaser DCE and switch to tab "Template".
You see a default template, which will be output in frontend for each instance (content element) of this DCE.
In this editor, you can define what TYPO3 should display, right in place. You can also load template files if you want.
The dropdown above the template field shows different items you can choose from. It displays the fields you have
defined and some other very helpful stuff:
Now, we build the frontend output that we want, for each content element based on this DCE.
The template engine here is Fluid:
We use variables pointing to the fields we've defined before, e.g. {field.title}.
When you want to output HTML, you need to use format.html view helper of Fluid. You can use it like
in the example above, or inline: {field.description -> f:format.html()}. Also, we use the for view helper in
Fluid to iterate over {field.images}. It's an array of FileReferences, which can get directly passed to the
image view helper.
When we save the DCE, clear the system caches (!) and create a new content element based on this DCE,
we see this output (in backend and frontend):
The Backend View
So far we have defined the fields of our content element and the frontend output.
But how is the content element displayed in the backend?
Well okay, it displays the title of the DCE we have defined. But we do not see any differences when we have two of these
content elements on the same page. Let's change this, by configuring the Simple backend view
in Backend Template tab.
Here you can define which (single) field should be displayed as header (and label in list view). And which fields
should also get displayed in bodytext. When we choose all options from bodytext field (but DCE title), we get more
info about our content element instances:
This saves much time and helps you to build fast new content elements.
Hint
The size of the images displayed in Simple Backend View and the crop limit of long text is configurable via PageTS.
DCE Container
Until now, you know the very basics of how DCE works. Let's use a more intermediate feature as of the last step in this
tutorial, which is potentially helpful for you: DCE Container
First, let's see the output of our content elements in the HTML source code of frontend output.
We have placed two content elements on a page:
When we compare this HTML source with the Fluid template from above, we will see our code, with filled placeholders.
Each content element is wrapped with <div class="dce"></div>, because we have defined it in our template.
DCE Containers help you to wrap all those standalone elements with a custom container template.
First, you need to enable the feature:
Just by enabling the feature (and clearing the caches) we see an instant effect in HTML output:
We see two wraps:
dce-container This comes from the container template itself
tx-dce-container This is because we use the DefaultContainer Fluid layout (which is optional)
Also, the backend view has been upgraded, it displays a color (calculated based on uid of the first element in the
container):
Note
DCE container is no replacement for EXT:container or EXT:gridelements!
Because the container is just generated by convention and logic, it has no physical instance which can have its own
properties.
What's next?
Congratulations! You know how to create a first content element in DCE.
Check out the next section in the documentation Users manual to get an overview of the options and possibilities
DCE gives you.
Have fun! And when you have questions, check out the Support section :)
Users manual
Every option you can set while creating or modifying a DCE is described here in detail.
Mandatory fields are signed by a red border and exclamation icon. At least these fields have to be filled out.
Important
Always remember to clear the system cache, when you did changes to DCE.
Otherwise, they would not apply to backend and frontend!
On this tab, you can make the general settings. You can decide whether the element is visible or not, give it a
meaningful name and identifier and define all the fields that are needed.
Title
This is the name of the DCE, which is also shown in the type selection of a content element.
You can point to LLL: references here and translate the title for different languages.
Identifier
The identifier is used as CType for new content elements based on this DCE. All identifiers of DCE are prefixed
with "dce_". For example: "dce_example". When the identifier of a DCE remains empty, the old syntax based on uid is
used automatically. The identifier must be written in lowercase, undercores are allowed.
Example: dce_dceuid1 or dce_what_ever
Inactive
When the DCE is inactive or hidden, it is not shown as the type when a content element is created.
It is only shown in the DCE BE module.
Fields
In the fields section, you can add a number of different fields that this DCE should contain.
You have to add at least one field.
A field has three types available:
Element
This is a field in your new content element, like a text field, a checkbox, an image or a
whole rich text editor (RTE). The composition for this field is done in the configuration.
All TCA field types are supported.
Tab
This creates a new tab register. All fields that are defined below this tab are shown in BE on a new tab page.
You may also rename the first "General" tab by creating a tab as the first item.
SectionIt is highly encouraged to not use sections anymore!
Check if DCE Container can help you or use EXT:container for your purposes.
Common to all types is the title field, where you define a speaking label for the editor.
You can use LLL: reference here. For the type Tab there are no more options to define.
Caution
When you add/update tabs and/or rearrange fields, the FlexForm structure changes!
Already existing content elements with FlexForm data, need to get migrated, afterwards.
Field options
For the default type Element you have to define a title (with LLL: support) and a variable name which is
to be used in the Fluid template. Variable names have to be written in lowerCamelCase and the variable names must
be unique inside each DCE.
Note
The configuration for the fields is stored in FlexForm (XML) format. Look for <el> in the FlexForms section
of the T3DataStructure
documentation to get detailed information for the definition of the field configuration.
To make it a bit easier there is a handy select box provided with the most used possible input field types.
If you select one entry the corresponding FlexForm XML code is inserted in the configuration input field.
For fields which use the TCA types group, select or inline, there are additional configuration attributes
provided by DCE available.
dce_load_schema
<dce_load_schema>1</dce_load_schema>
Copied!
When adding a group field and link it with e.g. News (by Georg Ringer), then the field contains a comma-delimited list
with uids of the selected news. That is not very useful in Fluid templates.
But when this attribute is activated, the used table is inspected. If an Extbase model and repository exist for this
table then the repository is instantiated and a findByUid() is called for every uid. The complete Extbase models are
then taken over to the Fluid template (as an array).
If the table is not part of an Extbase extension, the corresponding record is loaded from the database and handed
over as an associated array.
Caution
This function works only with one table, if you configure more tables it does not work.
Using the table tt_content and adding content elements which are based on another DCE, automatically the
corresponding DCE will be loaded and filled. In the template of the second DCE the template of the inserted DCE can be
called and rendered:
You need to use the raw view helper of Fluid because otherwise the rendered HTML will be escaped.
If you use the f:format.html view helper the curly braces get escaped and variables will not be interpreted anymore.
It is also possible to access directly the value of single fields:
Uses this class (and its repository) instead of guessing the model class name from table name.
dce_get_fal_objects
<dce_get_fal_objects>1</dce_get_fal_objects>
Copied!
If you have defined a FAL field and this attribute is activated, the value is directly replaced with a
TYPO3\CMS\Core\Resource\File object from the repository.
Setting this attribute ignores the enable fields of the requested table. All enable fields like deleted, hidden,
starttime, endtime get ignored then. This can be used for outputting hidden records.
If you load a page via group field, then always this page is loaded, regardless of the language that is just used.
Using this attribute shows the translated page if it exists ($GLOBALS['TSFE']->sys_page->getPageOverlay()).
That also works with other records, not only with records of the pages table, then getRecordOverlay() will be used.
dce_skip_translation
<dce_skip_translation>1</dce_skip_translation>
Copied!
When a DCE field got this option set, DCE fields act like l10n_mode => 'exclude' in TCA. Normally FlexForms does
not support this behaviour.
In backend, a field with this option set is only visible, when:
You are on default language (sys_language_uid = 0) or
the translated DCE content element has no l18n_parent set
To achieve this, DCE modifies the displayCond for the field, in XML configuration - when you already defined some
display conditions, they get merged (using <and>).
In frontend, the field value will get overwritten by the field value of the l18n_parent-element, no matter which values
are stored in pi_flexform.
On this tab, you define the template which is used for displaying the content of the DCE in the FE.
You can use the full power of Fluid at this place.
Template type
Tip
There are several templates a DCE can have. These options apply to all of them.
File
The option File let you choose a file that contains the Fluid content that should be used as the template for
this DCE. The file name is selected in the "Template file (fluid)" input field.
This option makes it possible that you put the templates under revision control due to the fact that the files are
stored in the file system.
The EXT: syntax is supported and encouraged to use, to point to template files provided by a template extension.
Caution
The t3://file=uid=1 syntax is still supported, but will be removed in next major version of DCE.
Template files should not be stored using FAL, which requires additional database queries, just to the path of the
template file.
Inline
The default template type Inline let you directly edit the content of the Fluid template inside the code mirror editor
of the "Template content (fluid)" entry field.
No namespace declaration
Since DCE 2.0 you do not need to provide the namespace declaration in each template. "dce:" is registered globally as
available namespace in Fluid templates.
Just skip the namespace line. But it is not problematic when this line is still left in the template.
Dynamic Templating
With the select box in the "Template content (fluid)" section you can insert variables and view helpers into the
template. The selected variable or view helper is inserted at the current cursor position in the template.
There are several groups inside the select box, which offers you help to work with Fluid:
Available variables
Available base variables
Famous view helpers
DCE view helpers
Available variables
This group shows all previously defined variables. You have to save the DCE before newly created fields appear in the
dropdown field. All custom variables are available with:
{field.nameOfVariable}
Copied!
Available base variables
Besides the custom created variables, they are also some variables existing which are available in all DCEs:
{dce} - The DCE object. To access field values use: {dce.get.fieldName}
{contentObject} and {data} - The content object row, this DCE instance is based on. It contains all tt_content properties.
{TSFE} - The TypoScript frontend controller (only available in frontend - deprecated, will get removed with TYPO3 v14)
{page} - The current page record (only available in frontend)
{pageInformation} - The PageInformation object (only available in frontend, since TYPO3 v13)
{site} - The current site instance (only available in frontend)
{tsSetup} - TypoScript setup of the current page (only available in frontend)
Famous view helper
This group lists often used view helpers provided by Fluid itself.
Detailed information about the Fluid view helper you will find in the official TYPO3 documentation
f:count
f:debug
f:for
f:format.crop
f:format.html
f:if
f:image
f:link.email
f:link.external
f:link.page
f:render
DCE view helpers
DCE also provides own view helpers, which can help using the field data in Fluid.
Tip
When you select a DCE view helper from the dropdown above inline code editor,
you will get an example pasted to the current cursor position.
dce:arrayGetIndex
Normally you can access array values with {array.0}, {array.1}, etc. if they have numeric keys. This view helper
converts named keys to numeric ones. Furthermore if you are able to set the index dynamically (i.e. from variable).
Index default is 0.
Gets $_GET or $_POST variables from current request.
Example:
{dce:GP(subject:'myCoolGetParameter')}
Copied!
Caution
Never use this view helper for direct output!! This would provoke XSS (Cross-site scripting).
dce:explode
Performs trimExplode (of GeneralUtility) to given string and returns an array.
Available options are: delimiter (default: ,) and removeEmpty (1).
Example:
{string -> dce:explode(delimiter:'\n')}
Copied!
dce:fal
Get file references in FAL. The option contentObject must pass the contentObject to the view helper,
the option field must contain the variable name of the field which contains the media.
You do not need to use the FAL view helper anymore, to access your images.
With <dce_load_schema>1</dce_load_schema> in your FAL field configuration, the FAL references get
resolved automatically.
dce:fileInfoViewHelper
Useful to fetch informations about a single sys_file record, you need to deal with when using section fields.
Most common attributes are: title, description, alternative, width, height, name, extension, size and uid.
Performs strtolower on given subject and converts string to lower case.
Example:
{field.text -> dce:format.strtolower()}
Copied!
dce:format.tiny
Removes tabs and line breaks.
Example:
<dce:format.tiny>
Removes tabs and
linebreaks.
</dce:format.tiny>
Copied!
dce:format.ucfirst
Convert a string's first character to uppercase.
Example:
{variable -> dce:format.ucfirst()}
Copied!
dce:format.wrapWithCurlyBraces
Use this view helper if you want to wrap something with curly braces {}. Available options are: prepend and append,
which add strings before or after the given variable, but inside of curly braces.
DCE Container is a new feature introduced in DCE 1.3. It allows you to wrap several content elements based on a
certain DCE with a Fluid template.
This is especially useful for slider libraries (for example). If you want to create one content element for one slide,
but you need to wrap all slides with a container <div> element, which initializes the functionality of the library.
First, you need to enable the feature:
Enable DCE Container
Enables/Disables DCE Container feature. This option influences the frontend rendering instantly.
When enabled, all content elements (tt_content) in a row based on this DCE are wrapped with the DCE container template.
The content elements "in the row":
base on the same DCE (with enabled DCE container feature)
are located on the same pid
are located in the same sys_language_uid
are located in the same colPos
Any other content element type interrupts the container.
Caution
Shortcuts are supported, but when your Container starts with a CType:"shortcut" item, it will fail.
Note
Since DCE version 2.8, DCE container also works inside of EXT:news detail view. Thanks to web-crossing GmbH
for sponsoring.
Container item limit
You can set an item limit (default: 0 / disabled) to limit the number of content elements a container may have.
When the the limit is reached, the next content element starts a new container.
Hide other container items, when detail page is triggered
When the DCE container and the detail page feature is enabled, this option makes it more comfortable to hide
all other content elements, which' detail page template is not triggered.
When this checkbox is enabled, all items in a container are hidden, if one item in the container is triggered by
detail page GET parameter. In this case, the container template is still rendered, just with a single item.
Other containers are not affected.
Template type
Like the default frontend template of DCE, you can outsource the code of the container to file.
DCE Container template
This template contains the code of the container wrapped around all DCEs within the container.
All DCEs in the container are stored inside the variable {dces} which is an array of Dce model instances.
So when you iterate over the dces array (using f:for loop) you can access single field values or render the default
template. So this partial is basically this:
When DCE container is enabled, each DCE has the new attribute containerIterator available,
which allows you to get info about the position of the DCE inside of the container, like the iterator in Fluid
you know from f:for loop:
{dce.containerIterator.total}
{dce.containerIterator.index}
{dce.containerIterator.cycle}
{dce.containerIterator.isEven}
{dce.containerIterator.isOdd}
{dce.containerIterator.isFirst}
{dce.containerIterator.isLast}
Container in backend
When you are using the Simple Backend View, you get a color mark for each content element:
The colors being used can be adjusted using PageTS (on root level):
By default, DCE provides ten color codes, which are picked based on the uid of the first content element in the
container.
Start new container
In content elements you also got a new option when DCE container is enabled:
When this checkbox is enabled, a new container is created, like in the screenshot above. With this, you can interrupt
containers manually.
Backend Template
Each DCE has not only a template for the frontend output, but also for the backend output. Without a backend template
you will not be able to see differences in your content elements, in the page or list view.
DCE provides two ways to set up the backend template:
Simple Backend View and
Manual Backend Fluid template
Simple Backend View
The Simple Backend View allows you to define fields you want to display, just by clicking it.
This example looks like this in backend:
Expression for header field
Since DCE 2.7 you can enable a checkbox, which reveals an input field. There you can use Symfony Expressions to
output more than one field in content element's header.
Tip
The header is also used as label (in list view and select dropdowns).
This header expression will - for example - generate the following header: Teaser: My second teaser
When you disable the Simple Backend View, you can enter (or reference to a file) a template using the "BackendTemplate"
Fluid layout, which has two sections: header and bodytext
<f:layoutname="BackendTemplate" /><f:sectionname="header"><strong>{dce.title}</strong><br></f:section><f:sectionname="bodytext">
Your backend template goes here...
</f:section>
Copied!
Note
Currently, it is not possible to access to DCE container info in manual backend template.
Icon & Wizard
Here you can define an icon used for the new content element and control appearance in new content element wizard.
DCE icon
The icon that is displayed in front of the entry in the wizard list can be chosen from a large number of available
icons. You can also choose "custom", which displays a new field to select the custom icon.
The icon also applies to CType icon.
Custom icon (24x24 pixel)
If none of the included icons fits your imagination you can also upload an icon in the format SVG, PNG or GIF
with 24x24 pixel.
Show DCE in content element Wizard
When this option is enabled then an entry for this DCE is added to the list of the New Content Element Wizard.
Wizard category
You can select here in which category of the wizard the DCE should appear. Besides a new category
"Dynamic content elements" also the TYPO3 own categories are available.
Wizard description
This is a short description text which is shown in the wizard and should describe what is the function of this
content element. It can be also be left empty.
Detail page
The detail page can be used to display the fields of the DCE in another manner. For example, if you have many fields
defined for your DCE you can display the most important fields with the normal template
and the complete amount of fields with the detail template.
The decision to display either the normal template or the detail page template is done by detecting the
detail page identifier (GET parameter). If it is found and it contains the uid of the actually shown DCE, the
content is rendered with the detail page template otherwise the normal template is used.
Important
When detail page template rendering is triggered, this has no effect on other content elements on the current page!
Enable detail page
To enable the functionality for using a detail page you have to check this option.
Detail page identifier (GET parameter)
This is the parameter which must be used in the GET parameter of the URL to enable the display of the detail page.
The value of this GET parameter must be the uid of the displayed content object, to trigger the detail page template.
You should avoid using a parameter name, which is already in use, like "id", "type" or "L".
Slug expression
Since DCE 2.6.0 a detail page can have a beautiful URL, thanks to TYPO3's routing enhancer, available since TYPO3 v9.
This slug expression field controls how the slug is being build.
You can choose a single field or multiple, thanks to Symfony's expression language.
All slugs generated by DCE are sanitized. The only chars allowed are a-z, 0-9 and -.
All other chars, get replaced by dash -. Double dashes are trimmed to one dash.
Here you can do the exact same thing, as in slug expression field, but this expression is used for the
pagetitle of the detail page.
Use slug expression as page title
With this option enabled, the current page title gets modified, based on the given slug expression.
In opposite to slugs itself, generated DCE detail page titles are not sanitized (e.g. convert spaces to dashes).
You can choose between four options:
No, keep title as it is (default)
Yes, overwrite the current page title
Yes, prepend slug content to current page title
Yes, append slug content to current page title
When selecting "prepend" (3) or "append" (4), the generated DCE detail page title gets separated by a configurable
string. By default it separates the DCE and the page title by ' - '.
You can configure this by TypoScript, this is the default configuration DCE ships:
Those values are used in a stdWrap noTrimWrap
function.
Template type
Like the normal template you can choose between the inline template code and using a template file.
Detail page template (Fluid)
Using the inline template type you have to insert the template code in the same manner as for the normal template.
How to create a link to detail template
In your "normal" template you probably want a link, to trigger the detail template for this content element.
Actually, it is pretty easy to create such a link in Fluid template:
<f:link.pageadditionalParams="{detailDceUid:contentObject.uid}">
Show detail template of this content element
</f:link.page>
Copied!
Note
It is not possible to activate two content element detail pages at once.
This tab contains all settings which are difficult to put in a category.
Cache DCE frontend plugin
This option activates or deactivates the caching of the DCE in the frontend. Every DCE that should be available in the
the frontend must be initialized in the localconf.php with calling the method ExtensionUtility::configurePlugin().
This option takes effect if the showAction of the DceController is cached or non-cached.
Direct output
With this option enabled you bypass fluid_styled_content.
Instead of using lib.contentElement, the DCE controller action is used directly.
This brings a significant performances boost and removes any wrappings defined by e.g. fluid_styled_content
(<div id="c123" ...>).
This option is enabled by default, separately for each DCE.
Note
When DCE container feature is enabled the direct output for this DCE is always enabled.
FlexForm label
Defines the text displayed in the content element:
Enable access tab in backend
If this option is activated a tab with the access rights is shown in the backend. Here you can define detailed,
when the DCE is to be shown and who is allowed to see the DCE. When this checkbox is enabled, the enabled fields
disappear from palette fields automatically, if set.
Enable media tab in backend
This option is only available when EXT:fluid_styled_content is installed. If this option is activated a tab with
media (FAL) field is shown in the backend.
You can access {contentObject.assets}` or {contentObject.media}`` variable in Fluid template.
It contains an array of \TYPO3\CMS\Core\Resource\FileReference.
Enable categories tab in backend
If this option is activated a tab with category picker is shown in the backend.
You can access {contentObject.categories} variable in Fluid template.
It contains an array of \TYPO3\CMS\Extbase\Domain\Model\Category.
DCE palette fields
This is a list of fields which should be shown in the head area of this DCE in the backend.
The default value is this: sys_language_uid, l18n_parent, colPos, spaceBefore, spaceAfter, section_frame, hidden
Prevent header copy suffix
Caution
This option is disabled for TYPO3 v13 and higher.
Empty header field in copied tt_content element, stays empty in copy.
If this checkbox is checked (enabled by default) a copied tt_content record, based on this DCE, will not append
"Copy (1)" to record's header. It uses the header contents of the original content record.
Fluid layout and partial root path
Layouts and partials are a part of Fluid templates and are used to avoid redundancies and keep the code cleaner.
Here you can define Fluid templates folders where to find the layouts and the partials.
With TypoScript you can also set up multiple folder paths for layouts and partials with priority order.
Under Admin Tools in the main navigation of TYPO3 backend you find "DCE" which leads to this dashboard:
Dashboard
On the dashboard, you see all DCEs you have created.
Hint
DCEs are TCA records stored on pid=0 (root level)
You see pieces of information for each DCE:
Status (enabled/disabled)
Identifier
uid
Usage (amount of content elements using this DCE)
- click on it, to see more details
Infos about features used, like DCE container, TCA mappings
Amount of fields used in this DCE
Also when you have mapped values to TCA columns of tt_content, you get an Update TCA Mappings button,
which updates the values of mapped columns, by given FlexForm values.
More stuff
In the backend module, you also find helpful links to Documentation, Facebook page, etc.
Also, you can clear the system caches, switch to list view and create and edit DCEs.
You can donate and see other donators in the hall of fame.
TCA Mapping
Since DCE 1.2 you are able to map the field values of your DCEs to tt_content columns.
DCE is also able to create new columns if necessary.
When creating new columns the following options have the following effect:
New TCA field name:
Name of the column in database and TCA. You are free to choose the name. Nothing gets prepended.
It is recommended to use_underscores instead of usingCamelCase.
New TCA field type:
This is the type of field in the database. Example: varchar(255) DEFAULT '' NOT NULL.
You can also use the keyword auto. DCE will choose a proper SQL field type based on chosen configuration type in
FlexForm.
Of course, you can also choose an existing tt_content column. DCE introduced the tx_dce_index column which can get
used to index content for search engines (like ke_search or solr).
Note
Since DCE 2.2, contents of DCE fields which has been mapped with "tx_dce_index", are also searched for when using
the global LiveSearch in TYPO3 backend. Since TYPO3 9.2 the search in list view, also respects "tx_dce_index"
contents.
When you point two DCE fields (or more) to the same TCA column, the contents of the field become appended
(by 2x PHP_EOL).
Every time you change a content element based on DCE with TCA mappings, the TCA values will get written,
when saving/creating the content element.
If you want to update the values, you can call an update script (Update TCA mappings) in DCE backend module.
User conditions
User conditions can be used in the TypoScript setup. DCE provides such a user condition:
DceOnCurrentPage
This user condition checks if the current page contains a content element based on given DCE.
The 42 is a sample for the uid of a DCE.
If you have defined an identifier, you can also use it in user condition parameter.
Code Caching
DCE generates PHP code and XML for new content elements during TYPO3's bootstrapping. To decrease database queries
during this process, DCE 2.2 introduced an own small CacheManager.
By default the code cache for DCEs is enabled.
Caution
Any changes made to a DCE or a DCE field, require to clear TYPO3's system cache. Otherwise changes are not visible
in backend or frontend.
Flags
disable_dce_code_cache
You can disable the DCE code cache entirely, using the following configuration in ext_localconf.php:
This will tell DCE to always invalidate and recreate cache files. Use this for development purposes only!
When you disable TYPO3's system cache, you also need to disable DCE code cache, to get fully uncached results.
Why DCE ships its own Cache Manager?
In DCE 2.1 the TYPO3's core cache manager has been used to cache DCE code. But TYPO3 does not allow to use its
Cache Manager during bootstrapping (limbo mode) in TYPO3 10 anymore. Therefore DCE provides it's own cache manager.
The shipped cache manager uses the same paths as TYPO3 uses for its code cache.
When clearing TYPO3's system caches, the DCE code cache also gets cleared.
Faking detail pages
With DCE 2.6.0 a new feature has been introduced, which allows you to simulate or fake detail pages,
based on DCE content elements: Slugs and custom titles for DCE detail pages
Thanks to Symfony Expression Language, you can use multiple DCE fields as slug
Field contents used for slug, get sanitized
Fallback if slugs are not unique (in this case, the uid of content element is appended to slug)
Modify current page title on detail page
based on own title slug expression
you can replace, prepend or append the DCE detail page title
Installation
Once you've upgraded to DCE 2.6, you just need to apply the following routing enhancer configuration
in your sites configuration yaml:
routeEnhancers:DceWithDetailpage:# you are free to choose a unique name heretype:SimpleroutePath:'/show/{detailDceUid}'# the given argument, must match with set detailpage_identifieraspects:detailDceUid:# Same heretype:PersistedAliasMappertableName:tt_contentrouteFieldName:tx_dce_slug
Copied!
Now, all DCEs with detail page enabled and identifier set to detailDceUid get beautified slugs.
Configuration
On tab "Detail page" in every DCE you find three new options:
DCE adds a new column tx_dce_slug to tt_content table. Only content elements based on DCEs with detail page enabled
and slug expression set, use this new field.
An after-save-hook updates the slug every time:
a content element get updated (or created)
the slug expression in DCE changed
then, all content elements existing, based on current DCE, get updated
slugs get removed, when slug expression is empty
With this static slug set, the routing enhancer configuration works with standard PersistedAliasMapper.
Tips
To make the illusion of a detail page perfect, here are some tips for you.
Hide other content elements
Tip
Since DCE 2.3, with enabled DCE container feature, you can automatically hide all other container items.
Check out the option, "Hide other container items, when detail page is triggered" in DCE Container options.
This checkbox is only available, when DCE container and detail page features are enabled.
If you have more DCEs with detail templates on one page, the template will just switch for one of your content elements.
The other DCE will still be visible and displays the normal template.
When you want to hide all other content elements you need to do some typoscript.
This small snippet checks if the GET param "detailDceUid" is set. If it is set, it tells the select function in
CSS Styled content, to display just this one content element, by passing the GET parameter value to the query.
Of course, we need to avoid SQL injection, by casting the value to an integer by using (stdWrap.)intval.
This example removes all content element from normal column. If you want to remove all elements but the selected one in
another col, you just need to write eg. "styles.content.getLeft" or ".getRight" or ".getBorder".
Caution: This snippet will probably not work, because mostly TYPO3 Integrators uses this
to assign the contents to the template:
page.10 < styles.content.get
Copied!
The lower than sign (<) copies the given value. But with our snippet above we override the original one.
The copy will not be affected. The easiest way would be to use a reference instead:
page.10 =< styles.content.get
Copied!
Then you are able to change something in CSS Styled Content typoscript, which also affects the output.
Bootstrap Package
In Bootstrap Package fetching content elements happens a bit different. Here, lib.dynamicContent is utilized by
the f:cObject view helper from within the templates, so we modify this lib:
Then, DCE content elements with detailpage enabled will also provide an entry in XML sitemap pages section.
Priority and change frequency is taken from the page record, where the DCE is located on.
When composer is done you need to enable the extension in the extension manager.
Without composer
You can also fetch DCE from TER and install it the old-fashioned way.
Tip
You need to enable the extension in Extension Manager with or without composer in use!
Or use CLI tools for that.
DCE provides no further options here.
Gridelements notice
Caution, when you also use EXT:gridelements in your TYPO3 project!
It can happen that DCE content elements have no contents available in Fluid template, when they
are located inside a grid column. This affects also all plugins, using pi_flexform.
When Gridelements is installed, it applies "magic" to pi_flexform by default. In order to make TYPO3 work as expected,
you need to disable this behaviour on your own, using TypoScript like this:
Since version 2.9 DCE is able to load and use template files from multiple locations, in frontend context.
You can check the default configuration in Configuration/TypoScript/setup.typoscript.
In the backend, when you are logged in as administrator, you can access the configuration of a content element based on
DCE, right inside the content element itself:
When you click on it, a popup appears which allows making changes for the current DCE:
Upgrading DCE
New version 3.0 of DCE and TYPO3 v12 contain various changes, which requires some manual adjustments.
DCE provides some upgrade wizards in install tool of TYPO3, which pop up when necessary.
Note
DCE 3.2 which introduced TYPO3 v13 support, does not require any manual adjustments or upgrades.
Steps
Just change your requirements section to
"t3/dce": "^3.0"
Copied!
and perform composer update.
Then go to TYPO3 Install Tool and check (and perform) the upgrade wizards and database compare!
Also, make sure you've deleted the DCE cache files (located in var/cache/code/cache_dce).
Templates in fileadmin
If you still use DCE templates located in fileadmin, loaded via FAL, you need to make manual adjustments.
The only way to load DCE template files, is using the EXT: syntax. For example:
This update checks all DCE field variables for being valid. If not it can correct them automatically.
MigrateDceFieldDatabaseRelationUpdate
In a very old version of DCE (0.x) the relations between DCE fields and DCEs were m:n. This wizard helps to migrate
old MM relations.
Warning
Do not delete the old MM tables, before you have performed this upgrade wizard.
Database compare offers you to delete the tables, what you can do, afterwards.
MigrateFlexformSheetIdentifierUpdate
In the past DCE named tabs in FlexForm configuration like this:
<sheet0></sheet0>
Copied!
But this has the effect that all your data is broken, when you change
the order of tabs in a DCE. Now the sheets have a named identifier. You
can set the identifier in the variable field which is also visible for
tab fields, now.
The FlexForm configuration looks like this now:
<sheet.tabGeneral></sheet.tabGeneral>
Copied!
The very first sheet has the identifier/variable "tabGeneral" by default. This wizard takes are about this.
FileToFalUpdate
Migrates old "type: group, internal_type: file" DCEs and content elements based on it.
Moving files from uploads/ to fileadmin/ and index by FAL. Also migrating section fields, with old image configurations.
Required for TYPO3 10 and higher.
All operations get logged in a separate log file:var/log/dce_update_wizards.log
What it does
First, the update wizard detects DCEs with fields which got the old type: group, internal_type: file configuration given.
It also checks the existence of media files within content elements based on those DCEs.
When executing the update wizard, the following changes get applied:
Create new directories in fileadmin (based on configured uploadfolder). When your files were located in /public/uploads/pics
the directory /public/fileadmin/uploads/pics will get created
Moving the media files
Indexing moved media files in FAL
Updating the old DCE field configuration with "FAL: File Abstraction Layer" configuration, respecting
- minitems
- maxitems
- allowed (file extensions)
Create new sys_file_reference entries (one for each media file)
Update tt_content's pi_flexform contents (replace comma separated list of file names with amount of existing sys_file_references)
The steps 4 and 5 work differently for section fields. Instead of using FAL/inline it creates a group field pointing to sys_file.
And instead of creating sys_file_reference entries, it writes the uids of sys_file in the pi_flexform.
In order to apply the changes to TYPO3's system caches, you need to flush all system caches manually.
Next steps
Unfortunately this migration script is not able to also update your Fluid templates automatically.
To help you with that, the log file (var/log/dce_update_wizards.log) contains a list of affected DCEs,
once the update wizard has been executed successfully.
There are two common cases:
Single image output
When you limited the field to one single image, your Fluid template probably looks like that, when it's about outputting the image:
<f:imagesrc="uploads/pics/{field.img}" />
Copied!
Because FAL always returns a collection of images, you need to change this output to:
<f:imageimage="{field.img.0}" />
Copied!
Because we use FAL now, we replace the src by the image attribute. Now, within {field.img.0} we got a
FileReference object. In order to only return the first (and only) image in this collection, we append .0 to the variable.
Also we get rid of the image base path, which get handled by FAL now.
Multi image output
When you already dealt with multiple images, your template most likely looks like that:
With the old configuration multiple images has been stored as comma separated string (e.g. image1.jpg,image2.jpg).
Now, field.images contains the collection of FileReference objects, which we can iterate through this way:
We just need to remove the usage of -> dce:explode() view helper and apply the same changes to the image view helper,
as we did for a single image.
This adjustment also works with images inside of sections (there, sys_file is being used instead of sys_file_reference).
InlineFalToFileUpdate
Migrates old FAL type: inline DCE field configurations to new type: file.
MigrateFlexformSysFileReferencesUpdate
Migrates records in sys_file_reference used by DCEs (FlexForms).
Extending configuration code snippets
Since DCE 3.1 you can extend the code snippets, provided in DCE field configuration field, using event listeners.
Writing the event listener
First, you need to create a new event listener class. The following example is located in your custom extension,
under the path Classes/EventListener/ModifyConfigurationTemplatesEventListener.php.
This example adds one new snippet group (at the beginning) and adds two field configuration code snippets:
<?phpnamespaceVendor\Extension\EventListener;
useT3\Dce\Event\ModifyConfigurationTemplateCodeSnippetsEvent;
classModifyConfigurationTemplatesEventListener{
publicfunctionmodify(ModifyConfigurationTemplateCodeSnippetsEvent $event): void{
$templates = $event->getTemplates();
// Adds new group "Custom templates" to the beginning of template array
$templates = ['My custom templates' => []] + $templates;
// Adds new example snippet
$templates['My custom templates']['My first example'] = <<<XML
<config>
<type>input</type>
<default>Example</default>
</config>
XML;// Adds another example to existing group
$templates['TYPE: text']['Another example'] = <<<XML
<config>
<type>text</type>
<!-- Your custom config goes here -->
</config>
XML;// Sets the modified templates array
$event->setTemplates($templates);
}
}
Copied!
Register the event listener
Next, you need to register the event listener.
Like any other event listener, you can register it in the Configuration/Services.yaml file, inside your extension:
You can simply iterate over the variable you have defined for the FAL field. Usage of old FAL view helper is not
necessary anymore. But you need to, add these two lines to the field configuration:
If you want to output only the first image you can use this one liner:
<f:image image="{field.myImages.0}" />
Copied!
Also the following tt_content fields (selectable in DCE options) are automatically resolved to an array of models,
for easy usage in Fluid template ({contentObject.xxx}):
media
categories
assets
How to nest DCE content elements?
In DCE you are able to nest other DCEs. That means you create a child DCE and a parent DCE and assign the children to
the parent. To enable the parent DCE to store children you need to add a new field with type "group".
Example field configuration (Variable name: "children"):
The dce_load_schema flag does the trick here. It realizes, that the tt_content item you have added is a DCE and returns
the DCE object itself. For any other content element, which is no DCE, it will return the tt_content row as
associative array.
But we assume, that you have just added content elements based on DCEs to the "children" field.
In your fluid template you can now do this:
The if condition in the treatIdAsReference is recommended because FileCollections returns different types of objects
depending of the type of the collection. Folder based collections returns the file directly, static based collections
a file reference. With this condition both cases are covered.
Note
When item is a FileReference you can pass it to image view helper like this:
<f:image image="{item}" maxWidth="250" />
How to readout an image in a Fluid template and give it a click enlarge function?
If you have defined a field in DCE where you can select images, then you can access the file name in the Fluid template.
The location where the image is stored is also defined in the TCA, which is mostly something like uploads/pics.
With the f:image view helper a thumbnail of the image, that should be shown, is issued.
TYPO3 creates an image with a reduced size and stores it in fileadmin/_processed_/.
In the href parameter of the link, which should show the big version of the image when it is clicked,
you use the f:uri.image view helper. In principle it is the same as the f:image view helper, but instead of an image
only a URL is created.
The benefit of using this view helper is that you also can use height and width to limit the size of the big image
(e.g. 800x600).
How to apply custom CKeditor configuration in DCE?
When you've defined a DCE field as RTE (rich text editor), you also defined the "richtextConfiguration" to be used,
e.g. "default", "minimal" or something custom.
The configuration in FlexForms will be overwritten by PageTS. When you've set e.g.
RTE.default.preset = minimal
Copied!
in PageTS, this will overwrite the "richtextConfiguration" of the DCE field. To avoid this issue, reset the
RTE.default.preset setting in PageTS.
How to render the content of an RTE field?
You have to enclose the RTE field with the format.html view helper to get the HTML tags of the RTE rendered.
<f:format.html>{field.rteField}</f:format.html>
Copied!
You can also use the inline notation:
{field.rteField -> f:format.html()}
Copied!
How to access variables of other DCE elements?
In frontend, you can access directly the TypoScript setup from current page, using {tsSetup.lib.xyz.value}.
How to migrate old image fields to new FAL fields?
Since DCE 2.9 there is a File to FAL update wizard existing. It moves all
referenced media files from /uploads to /fileadmin/uploads, indexes moved files to FAL and replace the filenames
in FlexForm data with sys_file or sys_file_reference uids.
How to link to the detail page?
The link to changeover to the detail page looks like this:
Where detailUid is the value of the field "Detail page identifier (get parameter)" you have set on the
"Detail page" tab.
How to wrap my content elements with a container?
Sometimes you need a wrapping element in HTML template, for all content elements from same type. I recommend to use
EXT:container, because it brings columns to content elements
which are structured in database.
You can also use the DCE feature DCE Container, which simulates a container for
certain content elements in a row, based on the same DCE.
How to change the long title in content wizard for DCE group
If you enable DCEs to be visible in content wizard, they can be grouped in a new group, introduced by DCE,
called "Dynamic Content Elements". This is in some cases to much text.
If you want to rename this group just use this code in PageTS:
mod.wizards.newContentElement.wizardItems.dce.header = Whatever you want
Copied!
You can also modify the position of the group, in PageTS. This is the default value:
[BUGFIX] Available templates switcher cuts of .xml instead of wrong .xlf
[BUGFIX] Only apply "Prevent header copy suffix" when status is "new" in after save hook
[TASK] Use new UpdateWizards also in TYPO3 9
[BUGFIX] Fix instantiating of ObjectManager
[TASK] Provide UpdateWizards, based on old Updates
2.4.1
[BUGFIX] Fix wrong version constraints
2.4.0
[FEATURE] TYPO3 10 Compatibility
2.3.1
[BUGFIX][!!!] Fix queries which build content elements
[BUGFIX] Do not throw exceptions in Content Element Generator
2.3.0
[FEATURE] Add new option "container_detail_autohide"
[BUGFIX] Fix Doctrine DBAL queries with empty field where clauses
2.2.1
[BUGFIX] Fix wrong escaping of quotes, in OutputPlugin Generator
[TASK] Improve error message, when a DCE Field has a mapping to a non-existing tt_content column
[TASK] Use Doctrine API to get list of table and column names
[TASK] Make DCE work, even without fluid_styled_content installed
[TASK] Add hint to documentation, that tab DCE fields changes the FlexForm structure
[TASK] Improve README.md
[BUGFIX] Fix hidden DCE container items
2.2.0
[FEATURE] New "Prevent header copy suffix" DCE option
[BUGFIX] Fix deprecated clear-cache call
[BUGFIX] Do not use "module-help" icon in DCE backend module
[FEATURE][!!!] Remove old TYPO3_DB calls with Doctrine DBAL
[FEATURE] Make mapped "tx_dce_index" contents searchable in backend
[TASK] Improve and document Code Caching feature
[BUGFIX] Use heredoc for generated FlexForm XML
[BUGFIX] Fix missing FQCN in generated PHP code
[FEATURE] Implement own CacheManager
2.1.0
[TASK] Use native database connection, when existing
[FEATURE][!!!] Re-implement Caching of generated PHP code
[TASK] Improve code snippets
[BUGFIX][!!!] Make access field values of child DCEs work in TYPO3 9 (before: {dce.fieldName}, now: {dce.get.fieldName})
[BUGFIX] Fix localizedUid conditions in FalViewHelper
2.0.6
[BUGFIX] Do not throw exception in backend when proper flexform missing
[FEATURE] Improve tx_dce_dce behaviour
[BUGFIX] Remove unused code which causes errors
2.0.5
[BUGFIX] Allow lowercase only for DCE identifier
[BUGFIX] Include tx_gridelements_columns in db query (thanks to Matthias Bernad)
2.0.4
[BUGFIX] Do not display "Edit DCE" button for all content elements
2.0.3
[BUGFIX] Add default value for tx_dce_dce column in tt_content table
[BUGFIX][!!!] Do not use hidden DCE fields
2.0.2
[TASK] Add "Upgrading DCE" to documentation
[BUGFIX] Allow null value for input in LanguageService::sL
[BUGFIX] Fix resolving of non-dce tt_content records
2.0.1
[BUGFIX] Check for correct table when resolving related records
2.0.0
Change package name and namespace to t3/dce and \T3\Dce
Add identifier to DCE, which allows to control the CType of the content element
Added direct_output mode
Fixed behaviour of detail pages
Global namespace registration for dce: in Fluid templates
Allow partials and layouts fallback
Add {$variable} to field configuration (used for FAL)
Add csh-description for all fields
Refactored user conditions (Symfony expression language)
Removed update check functionality
Removed all extension manager settings
Refactored and cleaned up code base
New FlexForm rendering (using DomDocument instead of FluidTemplate)
DCE is 100% deprecation notice free in TYPO3 9.5 LTS
Add complete documentation (!)
1.6.0
Added TYPO3 9.5 LTS and dropped TYPO3 7.6 LTS support
1.5.x
Completely refactored code injection (for TCA).
Instead of requiring a dynamic generated php file, the code is
dynamically executed, at the points where TYPO3 expects it.
So all cache clear functionality and options has been removed.
If you want to make new DCEs visible you need to clear the system
cache or disable the cache at all, like you need to do when modifying
the TCA manually.
DCE should behave exactly the same like before, just without need of
cache files in typo3temp.
Major bugfixes and improvements (DceContainer & SimpleBackendView)
Removed f:layout in DCE templates, by default
Applied refactorings
1.4.x
DCE major release with many new features and improvements
Also you can join the #ext-dce Slack channel on typo3.slack.com.
Donate
If you like the dce extension, feel free to donate some funds to support further development.
Contribute
If you are a developer and you want to submit improvements as code, you can fork https://github.com/a-r-m-i-n/dce
and make a pull request to DCE's master branch.
Thanks!
Reference to the headline
Copy and freely share the link
This link target has no permanent anchor assigned.The link below can be used, but is prone to change if the page gets moved.