Johannes Wachter
Johannes Wachter
Core Developer – Sulu GmbH
Sulu Core Developer and Open-Source Enthusiast.
2016-10-20

New in Sulu 1.4: New "teaser_selection" content type

In Sulu 1.4 we are introducing the new content type "teaser_selection" which can be used to display a list of "teasers". Contrary to "media_selection" and "contact_selection" – used for a single type of content like images, videos, contacts etc. – the "teaser_selection" type is able to display teasers of mixed types of content. The perfect example is a carousel that switches between teasers from pages, images and articles (provided by the brand new SuluArticleBundle).

Usage in the Template

This is how you add the content-type to a template:

<property name="teasers" type="teaser_selection">
    <meta>
        <title lang="en">Teaser selection</title>
        <title lang="de">Teaser-Auswahl</title>
    </meta>

    <params>
        <param name="present_as" type="collection">
            <param name="three">
                <meta>
                    <title lang="en">3 Columns</title>
                    <title lang="de">3 Spalten</title>
                </meta>
            </param>
            <param name="five">
                <meta>
                    <title lang="en">5 Columns</title>
                    <title lang="de">5 Spalten</title>
                </meta>
            </param>
        </param>
    </params>
</property>
Usage in the Template

Usage in the UI

The developer is now able to add pages, articles etc. The dropdown can differ depending on the  installed bundles.

On the right side of the content-type there is another dropdown which can be used by the developer to provide different visual styles.

The data for each of this types of teaser will be editable in the "Excerpt & Categories" tab. The teaser consists of the following properties:

  • Title
  • Description
  • One (or no) media
  • More-link text

Each of this values can be overwritten locally where it has been added.

Usage

In the Twig template the developer can rely on a "strict" datastructure no matter which kind of content was selected by the editor.

Extensibility

As i mentioned in the first part of this post this content-type is easily extensible. If you have custom content to be integrated in the teaser selection you can follow the Cookbook entry for "Provider for Teaser-Selection".