Teaser Implementation

a component development blueprint

The content element above is showing a teaser. The resource type of the teaser component is

composum/pages/components/element/teaser

The base implementation shipped as part of the Composum Pages Components is located in the /libs resource resolver root. The component declaration here

defines a placable component (cpp:Component primary type). Such a Sling component is registered by the Pages Component Manager automatically and offered in the various component type selector widgets for insertion into a container of a content page.

Teaser Scripting

teaser.jsp jsp
<%@page session="false" pageEncoding="UTF-8" %> <%@taglib prefix="cpp" uri="http://sling.composum.com/cppl/1.0" %> <cpp:defineObjects/> <cpp:model var="teaser" type="com.composum.pages.components.model.teaser.Teaser"> <cpp:include test="${teaser.valid}" replaceSelectors="${teaser.variation}"/> </cpp:model>

This looks very simple because the main template is delegation the rendering to the teasers variation declared by a property of the teaser. This property 'defined' in the teasers edit dialog.

Edit Dialog

The Model Class

This looks very simple because the main template is delegation the rendering to the teasers variation declared by a property of the teaser. This property 'defined' in the teasers edit dialog.

the default teaser variation

the other teaser variations

'bgimage' teaser

bgimage.jsp
<%@page session="false" pageEncoding="UTF-8" %> <%@taglib prefix="cpn" uri="http://sling.composum.com/cpnl/1.0" %> <%@taglib prefix="cpp" uri="http://sling.composum.com/cppl/1.0" %> <cpp:defineObjects/> <cpp:element var="teaser" type="com.composum.pages.components.model.teaser.Teaser" cssAdd="@{teaserCSS}_variation_bg-image" style="background-image:url(@{teaser.imageUrl})"> <cpp:dropZone property="image/imageRef" filter="asset:image"> <cpn:link test="${teaser.hasLink}" body="true" class="${teaserCSS}_link" href="${teaser.linkUrl}" target="${teaser.linkTarget}" title="${teaser.linkTitle}"> <cpn:div test="${teaser.hasIcon}" class="${teaserCSS}_icon"><i class="fa fa-${teaser.icon}"></i></cpn:div> <div class="${teaserCSS}_content"> <cpp:include replaceSelectors="${teaser.textSelector}"/> </div> </cpn:link> </cpp:dropZone> </cpp:element>

'bgvideo' teaser

bgvideo.jsp
<%@page session="false" pageEncoding="UTF-8" %> <%@taglib prefix="cpn" uri="http://sling.composum.com/cpnl/1.0" %> <%@taglib prefix="cpp" uri="http://sling.composum.com/cppl/1.0" %> <cpp:defineObjects/> <cpp:element var="teaser" type="com.composum.pages.components.model.teaser.Teaser" cssAdd="@{teaserCSS}_variation_bg-video"> <cpp:include path="video" resourceType="composum/pages/components/element/video/background" mode="none"/> </cpp:element>