By Sebastiaan de Jonge, published on Wednesday, October 19, 2016 at 13:00

It's important to keep your backend easily usable for editors. One of the things that can help with that is the use of the new content element wizards. 
These wizards are when a new content element is created from the Page module, or at the top of the List module (Create a new content element > Click here for wizard!).

Creating these for your own custom content elements is also a matter of minutes work, and it will make the life of your editors easier.

Getting Started

First of all, you will need some custom elements of course. I will continue on the example from my previous post. In there three new elements were added, which I will now add to the wizards.

When you look at the wizard, you can see there are four different tabs by default. Initially I will add my elements to the first tab Typical page content. A bit further down I will create a custom tab as well and add the items there.

Adding Content Elements

The first item to add is the Panel. Do so by adding the following Page TSconfig, for example to the root page in your page tree.

mod.wizards.newContentElement.wizardItems.common {
    elements {
        sdjexample_panel {
            iconIdentifier = content-table
            title = LLL:EXT:sdj_example/Resources/Private/Language/ContentElement.xlf:sdjexample_panel.title
            description = LLL:EXT:sdj_example/Resources/Private/Language/ContentElement.xlf:sdjexample_panel.description
            tt_content_defValues {
                CType = sdjexample_panel
            }
        }
    }
    show := addToList(sdjexample_panel)
}

This will result in the following view inside the wizard.

That was pretty easy right?

Changing the icon

The iconIdentifier determines what icon is placed before the element, which should be in some form a visual representation of the element. I've chosen content-table because it kind of looks like my panel.

There are plenty of other options available though. You can find all items which are available by default inside the TYPO3\CMS\Core\Imaging\IconRegistry class ($icons).

It's also possible to add custom icons to the registry, however it won't be covered in this post.

Default values

If you look closely you can see that tt_content_defValues is used to set the default CType for the content element. You can add other settings here as well, for example to add a default title or default background color for specific items.

Different tabs

On the first line, mod.wizards.newContentElement.wizardItems.common defines under which tab the element will be placed. In this case the common tab is Typical page content. Here's a list of all default tabs:

  • common (Typical page content)
  • form (Form elements)
  • plugin (Plugins)
  • special (Special elements)

Custom tabs

To organize the elements a bit, I will place my new elements under a new tab. These are also very easy to add, like so:

mod.wizards.newContentElement.wizardItems.bootstrap {
    header = LLL:EXT:sdj_example/Resources/Private/Language/ContentElement.xlf:tab.bootstrap
    after = common
    elements {
        // ..
    }

This will add a header to the new bootstrap group, and place it after the common items.

Final result

When you put it all together you get following code:

mod.wizards.newContentElement.wizardItems.bootstrap {
    header = LLL:EXT:sdj_example/Resources/Private/Language/ContentElement.xlf:tab.bootstrap
    after = common
    elements {
        sdjexample_panel {
            iconIdentifier = content-table
            title = LLL:EXT:sdj_example/Resources/Private/Language/ContentElement.xlf:sdjexample_panel.title
            description = LLL:EXT:sdj_example/Resources/Private/Language/ContentElement.xlf:sdjexample_panel.description
            tt_content_defValues {
                CType = sdjexample_panel
            }
        }
        sdjexample_alert {
            iconIdentifier = content-header
            title = LLL:EXT:sdj_example/Resources/Private/Language/ContentElement.xlf:sdjexample_alert.title
            description = LLL:EXT:sdj_example/Resources/Private/Language/ContentElement.xlf:sdjexample_alert.description
            tt_content_defValues {
                CType = sdjexample_alert
            }
        }
        sdjexample_well {
            iconIdentifier = content-header
            title = LLL:EXT:sdj_example/Resources/Private/Language/ContentElement.xlf:sdjexample_well.title
            description = LLL:EXT:sdj_example/Resources/Private/Language/ContentElement.xlf:sdjexample_well.description
            tt_content_defValues {
                CType = sdjexample_well
            }
        }
    }
    show = *
}

Since this is a new group, elements don't need to be added to the list. You can simply set show to * to show all items. You can also use show to remove items from an already existing group, such as common. For example, to hide certain elements from selection.

The result in the backend will look like this:

Automatically include Page TSconfig

It's also possible to automatically include your Page TSconfig for all pages. It can be done with the following snippet, which is placed inside the ext_localconf.php of your extension.

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
    "<INCLUDE_TYPOSCRIPT: source=\"FILE:EXT:{$_EXTKEY}/Configuration/TSconfig/IncludePage.ts\">"
);

Of course, the example is added as an attachment to this post!

Happy coding!