Content Elements and Parts
This chapter describes the structure of content elements.
Content elements are defined in an HTML or Handlebars file each.
They contain a single block parent element with the data-bsi-element attribute with a unique identifier for the content element.
The following listing illustrates a very simple content element:
<div data-bsi-element="logo">
<img src="logo.png" alt="My Company"/>
</div>
As we can see in the listing, data-bsi-element defines the identifier of the content element.
It must not contain any spaces.
The identifier corresponds to the value that can be used in the attribute called data-bsi-dropzone-allowed-elements in the dropzone.
The element marked with the identifier, when used, is inserted into the relevant dropzone (not only the child elements).
| The content editor specifically highlights the content elements. To make sure this works properly, all content elements must be block elements rather than inline elements. |
A content element can define one or more internal dropzones.
The definition is the same as for design.html and design.hbs.
For example, use it with a content element for a 3-column layout with three internal dropzones.
While the dropzones may be nested arbitrarily, please pay attention to usability.
Types
There are two distinct styles of content elements:
-
HTML-Elements: HTML-Elements only consist of HTML Element Parts. Element Parts specify a fixed structure of a DOM-subtree that is directly manipulated inside the content editor. This type has been supported ever since the release of BSI CX.
-
Handlebars-Elements: Handlebars-Elements use Handlebars as template engine. The element consists of Template Parts that specify parts of the element editor. The HTML of the element is created by rendering the Handlebars-Template with the variables exported by the Template Parts. Handlebars-Elements cannot include traditional HTML Element Parts.
Element Parts
A content element part references, inside a content element, an area (such as text or image) that can be edited directly with the BSI CX content editor.
The content element "text with image" knows, for example, the two areas image and plain-text.
The identifiers must be adopted exactly as they are.
The following listing illustrates the example:
<figure class="element text-with-image" data-bsi-element="text-with-image"> (1)
<img class="image" data-bsi-element-part="image" src="example.jpg"/> (2)
<figcaption class="text" data-bsi-element-part="plain-text">Lorem ipsum</figcaption> (3)
</figure>
| 1 | This is the content element definition. |
| 2 | The image part defines an editable image. |
| 3 | The plain-text part defines an editable plain text. |
The individual parts are likely to contain sample content already.
This content must fit in terms of the structure (e.g., only plain text with plain-text, and a correct table definition with table, etc.)
|
Plain Text
The part plain-text can be applied to any HTML element that can contain text.
The text is inserted within the element.
The element must not have children with other content element parts (content is removed).
A single-line text field without formatting is available as the editor.
<h1 data-bsi-element="title-h1" data-bsi-element-part="plain-text" class="element title-h1">Lorem ipsum</h1>
Configuration
-
studioLinkEnabled: This boolean value controls whether the 'CX Link' button is visible. Default is
false. -
multiline: This boolean value controls whether the field is single- or multiline. Default is
false. -
fieldHeight: This integer value controls the field height in the form of the content editor. Default is
5. The unit is Eclipse Scout grid height (Property 'h' in GridData).
Formatted Text
The part formatted-text can be applied to any HTML element that can contain text.
The element must not have children with other content element parts (content is removed).
The rich text field with a limited number of formatting options is available as an editor.
For more information about the available configuration options see chapter [rich-text-editor].
<section data-bsi-element="section" data-bsi-element-part="formatted-text">
<h1>Lorem ipsum dolor sit amet</h1>
<p>Proin porta <strong>pharetra est non</strong> molestie.</p>
<p><a href="https://www.example.org/">More</a></p>
</section>
HTML
| This part should only be used for prototyping purposes. |
The html part can be applied to any HTML element.
The code is inserted within the element.
The element must not have children with other content element parts (content is removed).
A text field is used as the editor.
HTML can be written directly into this field.
<div data-bsi-element="html" data-bsi-element-part="html">
<iframe src="https://www.openstreetmap.org/export/embed.html" style="height: 500px;"></iframe>
</div>
It is not allowed to place any data-bsi-element or data-bsi-element-part attributes inside the HTML code.
This won’t work as expected and leads to invalid content.
|
Video
The video part can be applied to any block level HTML element.
This part can be used to display information and thumbnails of external videos.
It can also be used to embed external videos.
Within the element, various elements can be used as placeholders:
-
Each
<iframe>element is used to embed an external video player. -
Each
<img>element with adata-bsi-video-thumbnailattribute is used to display the video thumbnail. -
Each HTML element with the
data-bsi-video-titleattribute is used to display the video title. -
Each HTML element with the
data-bsi-video-descriptionis used to display the video description. -
Each
<a>element with thedata-bsi-video-linkis used to place a link to the external video. The text of the hyperlink will not be touched, only thehrefattribute will be filled.
| Fetching the video’s title and description may requires an active API key for the appropriate provider. |
Boolean attributes like data-bsi-video-title require an empty value ="" or sample value like ="true".
|
The following external video providers are supported:
- YouTube
-
Without a configured API key, only the thumbnails are automatically picked. More information on obtaining a YouTube API key: https://developers.google.com/youtube/v3/getting-started
- Vimeo
-
The Vimeo-integration requires no additional configuration or credentials.
Be aware that there are two kinds of URLs involved:
One is the link to the video platform itself for the href attribute on the <a> tag and there is the embedded URL for the <iframe> player.
In the case of YouTube https://www.youtube.com/watch?v=YpnFs4aBLQA is the link to the video platform.
The corresponding embedded URL would be https://www.youtube.com/embed/YpnFs4aBLQA.
If you want to provide sample content for your element you may have to fill both URLs in the right tag.
The following listing illustrates the use of sample content for a simple video element:
<div class="element video" data-bsi-element="video-simple">
<div class="responsive-video" data-bsi-element-part="video" data-bsi-video-data-link="https://www.youtube.com/watch?v=YpnFs4aBLQA"> (1)
<iframe width="1120" height="630" frameborder="0" src="https://www.youtube.com/embed/YpnFs4aBLQA" allow="autoplay; encrypted-media" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> (2)
</div>
</div>
| 1 | The link to the video platform is placed inside the data-bsi-video-data-link attribute. |
| 2 | The embed video URL is placed inside the src attribute of the <iframe> tag. |
This results in the following content element:
A more complex video element would be the following:
<div class="element video" data-bsi-element="video-thumbnail">
<div class="video-thumbnail" data-bsi-element-part="video" data-bsi-video-data-link="https://www.youtube.com/watch?v=YpnFs4aBLQA"> (1)
<p>
<a href="https://www.youtube.com/watch?v=YpnFs4aBLQA" data-bsi-video-link="" target="_blank"> (2)
<img src="https://i.ytimg.com/vi/YpnFs4aBLQA/maxresdefault.jpg" alt="" data-bsi-video-thumbnail=""/> (3)
</a>
</p>
<h3 data-bsi-video-title="">BSI Tech Lovers</h3> (4)
<p data-bsi-video-description="">Für mehr WOW-Momente mit BSI. Monika Freiburghaus, Ralf Muri, Thomas Lindauer und Urs Frick zeigen Einblicke in ihre persönlichen WOW-Momente.</p> (5)
</div>
</div>
| 1 | The link to the video platform is placed inside the data-bsi-video-data-link attribute. |
| 2 | The link to the video platform is also placed inside the href attribute. |
| 3 | The placeholder image can also be part of the design, it is not mandatory to provide the URL to the real image here. |
| 4 | The content of the first tag marked with data-bsi-video-title will be used as placeholder for the title. |
| 5 | The content of the first tag marked with data-bsi-video-description will be used as placeholder for the video description. |
This results in the following content element:
The video part is quite powerful and can be used in various ways:
-
Enrich your landing page or website with embedded videos.
-
Use video thumbnails in your content.
-
Send emails with link, thumbnail, title and description of an external video.
Image
The image element part can only be placed inside of a <img> or <a> tag.
The source is inserted in the src attribute.
<div data-bsi-element="image-simple">
<img src="example.jpg" alt="Example image" data-bsi-element-part="image" />
</div>
It is not possible to omit the image of an image part.
Therefore it is mandatory to specify an image in the content editor.
Otherwise a validation error will occur.
srcset
By specifying the srcset attribute, the images are also scaled accordingly.
If a srcset attribute is present, the src attribute is set to the image at its highest resolution (according to the defined srcset).
If there is no srcset attribute, the selected image is not scaled and is placed directly as src.
For images with dynamic sources (the image is set through the story), the definition of the srcset is ignored.
If you set an image in the content editor, make sure it is of decent size. After saving the content, the image is scaled to the sizes specified in the srcset attribute and stored on the BSI CX resource server. Depending on the resolution of device that is requesting the landing page/website, a different resolution of the image is loaded.
We highly recommend to set the srcset attribute.
|
<div data-bsi-element="image-simple">
<img src="example-800w.jpg" srcset="example-480w.jpg 480w, example-800w.jpg 800w" alt="Example image" data-bsi-element-part="image" />
</div>
The attribute data-bsi-hide-link controls whether the field URL/internet address and the checkbox Open in new window is visible and editable in the content editor. A design developer may still wrap the image inside an <a> tag in the content element, but the user cannot change the link.
background-image
An arbitrary element which permits the use of a CSS background-image.
It places the CSS attribute background-image.
The image selection is available as the editor just like with the image part.
<div class="element scene" data-bsi-element="scene">
<div data-bsi-element-part="background-image" style="background-image: url('example.jpg')"></div>
</div>
table
A <div> oder <td> element with a table element as a direct child element.
The table content is filled according to the editor (including colgroup).
Colspan is not supported. On even or odd rows or columns, the CSS class even or odd is placed.
The <th> tag is used for header columns, if specified.
This part does not support <thead> and <tbody> tags.
| It is possible to use an iterator to generate dynamic tables. |
<div class="element table" data-bsi-element="simple-table" data-bsi-element-part="table">
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>42</td>
</tr>
</table>
</div>
iterator
An arbitrary element.
The attribute data-bsi-iterator can be defined on this element.
The attribute data-bsi-iterator-item must be defined on the element or on one of the included elements.
This defines the element to be duplicated.
If data-bsi-iterator is defined and the iterator does not provide any data, the entire element is removed.
Otherwise, only the element to be duplicated is marked with data-bsi-iterator-item.
A text field is used as the editor. The name of the iterator can be placed in this text field.
<div class="element iterator" data-bsi-element-part="iterator" data-bsi-iterator="Customer">
<div class="customer" data-bsi-iterator-item="Customer">
<dl>
<dt>Name</dt>
<dd>{Customer.name}</dd>
<dt>Address</dt>
<dd>{Customer.address}</dd>
</dl>
</div>
</div>
news-snippets
An arbitrary element.
Displays a news item.
Within the element, elements with the data-bsi-property attribute can be defined.
This attribute may have the following values: image, title, headline, or text.
The content of these elements is then replaced accordingly with the value of the selected news item.
In that context, elements from property title, headline, and text are mandatory.
If a link in BSI CX is configured into a news snippet, title and image are automatically supplemented with a link.
When generating the news list, the following CSS classes are automatically set on a news snippet to permit better styling of the individual elements:
| news-nth-X |
the position in the list. E.g., |
| odd |
odd position in the list |
| even |
even position in the list |
| first |
first news snippet |
| last |
last news snippet |
<div class="element news" data-bsi-element="news-snippets" data-bsi-element-part="news-snippets">
<div class="news-image element">
<img class="ns-image" src="placeholder.jpg" data-bsi-property="image"/>
</div>
<div class="news-text element">
<h2 class="ns-title" data-bsi-property="title">Breaking News</h2>
<p class="ns-headline" data-bsi-property="headline">Lorem ipsum dolor sit amet</p>
<p class="ns-text" data-bsi-property="text">Ea vis odio voluptua, pri ei facer denique.</p>
</div>
</div>
form
A <form> element.
The element must contain a submit button and may also contain a reset button.
Those buttons must be <input> elements.
In the form configuration, the reset button can be hidden or displayed.
In that case, the DOM attribute disabled is set on the input element.
The form element must contain an element with the data-bsi-form-validation attribute, and this attribute must contain an element with the data-bsi-form-validation-item attribute.
Within the element with data-bsi-form-validation, the element with data-bsi-form-validation-item is duplicated for each error in the server-side form validation, and the validation message is inserted as the content of the validation item element.
Boolean attributes like data-bsi-form-validation require an empty value ="" or sample value like ="true".
|
In addition to the display in the above-described element, a data-bsi-form-validation-message attribute is set for each defective form field.
It contains the validation error for the respective field.
The attribute can be used to style the field with CSS if there is an error (CSS selector checks for the presence of the attribute) or to display the error message with CSS and/or JavaScript in the respective field.
The following form fields can be marked as mandatory fields in the content editor.
If this is done, the required attribute is set in the relevant HTML element.
Thus, the mandatory elements are styled using the respective CSS selectors.
To exclude a certain form from BSI CX you set the data-bsi-form-ignore attribute on the form tag.
Any form with this marker will be left untouched by BSI CX.
<div class="element form" data-bsi-element="slim-form">
<form class="form form-wrapper" data-bsi-element-part="form" id="form">
<ul class="form-validation" data-bsi-form-validation="">
<li class="form-validation-item" data-bsi-form-validation-item=""></li>
</ul>
<div class="form-content" data-bsi-dropzone="form-content" data-bsi-dropzone-allowed-elements="form-field">
</div>
<div class="form-button-bar">
<input type="submit" class="form-button send" value="Senden" />
<input type="reset" class="form-button reset" value="Zurücksetzen" />
</div>
</form>
</div>
Dynamic Forms / Form-Field Rules
BSI CX supports dynamic forms. The feature provides a Domain‑Specific Language (DSL) in JSON, which is interpreted by the front-end and back-end. The DSL allows defining form-field rules, which can manipulate the DOM state dynamically. A simple example: a form-field rule defines that when a checkbox is clicked, a group of other fields (fieldset) becomes visible.
In order to support that feature in a BSI CX design, the design must set the feature flag formFieldRules in the design.json (see [feature-toggle]).
The design must also include the NPM module @bsi-cx/web-frontend and initialise the library, e.g.:
let module = window.bsiCxWebFrontend;
let fieldRules = new module.FieldRules();
fieldRules.init();
It is recommended to add a content-element for 'fieldset', which uses the HTML element with the same name and provides a dropzone which accepts other form-fields. The fieldset must have a configurable ID, which can be referenced by the form-field rules.
If the dynamic forms feature is active, the attribute data-bsi-json-document is set on the form element.
It stores the DSL as (encoded) JSON.
A BSI CX user can manage the form-field rules via GUI.
There’s a tab 'Form-field rules' in the form element part.
|
form-field
A <div> element.
Contains a <label> and an <input> element.
In the configuration, the label, initial value, mandatory field, and input type can be defined.
The following input types are supported:
| text |
For a simple text field. |
|
Input field, that accepts a valid e-mail address. |
|
| tel |
Input field, that accepts a phone number. |
| password |
A password input field, that shows |
| number |
An input field, that accepts only numbers. |
| range |
An input field, that shows a numeric range slider. |
| date |
An input field, that can be used to select a certain date. |
| datetime-local |
Input field, that accepts a date and a specific time. |
| time |
Input field, that accepts a time. |
| file |
Input field, that can be used to upload a file. |
To fixate the form field type, the data-bsi-form-field-fixed-type attribute can be used on the element.
Doing so allows the setup of a customized date field, for example.
The type of the form field is then set and cannot be changed in the content editor.
The attribute data-bsi-hide-required controls whether the mandatory checkbox is visible and editable in the content editor. If the checkbox is not shown, the original state of the required attribute is preserved, as defined by the content element.
In the configuration of form field parts in the design.json three optional text fields can be enabled:
{
"partId": "form-field",
"label": "Form Field",
"config": {
"infoTextEnabled": true, (1)
"mandatoryTextEnabled": true, (2)
"invalidTextEnabled": true (3)
}
}
| 1 | An informative text on the usage of the form field, saved into the data-bsi-form-info-text attribute on the form field element. |
| 2 | A text that can be shown to the user to indicate that a field is mandatory, saved into the data-bsi-form-mandatory-text attribute on the form field. |
| 3 | A text that can be shown to indicate the user input does not fulfill the necessary format, saved into the data-bsi-form-invalid-text attribute on the form field. |
Those three configuration options enable three fields in the editor of the form field part:
The values are written into custom HTML attributes that can be used in the design for client-side form validation.
| Be aware, that not all browsers support all types of input fields. Some browsers require a polyfill to handle certain types of form fields. It is up to the developer to use polyfills where this is required. |
<div class="form-field" data-bsi-element="date-field" data-bsi-element-part="form-field" data-bsi-form-field-fixed-type="">
<label for="date" class="label">Date</label>
<input id="date" class="input" type="date" value="2009-11-13" required="" data-bsi-form-mandatory-text="This field is mandatory." />
</div>
Boolean attributes like data-bsi-form-field-fixed-type require an empty value ="" or sample value like ="true".
|
form-checkbox
A <div> element.
Contains a <label> and an <input> element with the checkbox type.
The attribute data-bsi-hide-required controls whether the mandatory checkbox is visible and editable in the content editor. If the checkbox is not shown, the original state of the required attribute is preserved, as defined by the content element.
If enabled the data-bsi-form-info-text and data-bsi-form-mandatory-text attributes can be used on this element part. For further information on usage and how to enable them see form-field.
<div data-bsi-element="form-checkbox" data-bsi-element-part="form-checkbox" class="element checkbox">
<input type="checkbox" id="checkbox1" />
<label for="checkbox1">Checkbox 1</label>
</div>
form-textarea
A <div> element.
Contains a <label> and a <textarea> element.
The attribute data-bsi-hide-required controls whether the mandatory checkbox is visible and editable in the content editor. If the checkbox is not shown, the original state of the required attribute is preserved, as defined by the content element.
If enabled the data-bsi-form-info-text, data-bsi-form-mandatory-text and data-bsi-form-invalid-text attributes can be used on this element part. For further information on usage and how to enable them see form-field.
<div data-bsi-element="form-textarea" data-bsi-element-part="form-textarea" class="form-field form-element">
<label for="textarea" class="label">Description</label>
<textarea id="textarea" rows="5" cols="20" class="textarea" maxlength="500">Lorem ipsum</textarea>
</div>
form-select
A <div> element.
Contains a <label> and a <select> element with the elements option.
The pre-allocation of the element can be controlled with the data-bsi-value and data-bsi-value-list attributes.
The data-bsi-value attribute contains the preal-location, and the values available for selection are defined in the data-bsi-value-list attribute.
A line break (\n or \r\n) separates each of those.
To fixate the values that are available for selection, the data-bsi-form-select-fixed-value-list attribute can be set on the element.
Then, the list of values cannot be changed in the content editor.
Only the preselection can be changed.
The attribute data-bsi-hide-required controls whether the mandatory checkbox is visible and editable in the content editor. If the checkbox is not shown, the original state of the required attribute is preserved, as defined by the content element.
If enabled the data-bsi-form-info-text and data-bsi-form-mandatory-text attributes can be used on this element part. For further information on usage and how to enable them see form-field.
The multiple attribute is not supported.
|
<div data-bsi-element="form-select" data-bsi-element-part="form-select" class="form-select form-element" data-bsi-value-list="Yes
No
Unsure" data-bsi-value="No">
<label for="select" class="label">Decision</label>
<div class="select-wrapper">
<select size="1" id="select">
<option>Yes</option>
<option selected="">No</option>
<option>Unsure</option>
</select>
<div class="dropdown" role="presentation">a</div>
</div>
</div>
form-radio
A <div> element.
Contains a <label> and a <div> element as a radio group.
The radio group is marked with the data-bsi-radio-group attribute.
The radio group contains radio items.
These are identified with the data-bsi-radio-item attribute and contain a <label> and an <input> element with the radio type.
The preselection of this element can be controlled with the data-bsi-value and data-bsi-value-list attributes.
Same as the form-select part.
The same applies to the data-bsi-form-select-fixed-value-list attribute.
The attribute data-bsi-hide-required controls whether the mandatory checkbox is visible and editable in the content editor. If the checkbox is not shown, the original state of the required attribute is preserved, as defined by the content element.
If enabled the data-bsi-form-info-text and data-bsi-form-mandatory-text attributes can be used on this element part. For further information on usage and how to enable them see form-field.
<div data-bsi-element="form-radio" data-bsi-element-part="form-radio" class="form-radio form-element">
<label class="label">To be or not to be?</label>
<div data-bsi-radio-group=""> (1)
<div class="form-radio-item" data-bsi-radio-item=""> (2)
<input type="radio" id="radio1" />
<label for="radio1">Radio-Button 1</label>
</div>
</div>
</div>
| 1 | The data-bsi-radio-group element contains the prototype element. |
| 2 | The data-bsi-radio-item element is the prototype element. |
Be aware, that data-bsi-radio-item must be right inside data-bsi-radio-group.
Any intermediate element will be removed.
|
Boolean attributes like data-bsi-radio-item require an empty value ="" or sample value like ="true".
|
basic-dynamic-value-list
This part offers functionality for the integration of BSI Suite value lists into any HTML form, providing REST endpoints for the purpose of retrieving values from such lists.
| This element part is a backport of the dynamic value list template part. Check this chapter for a detailed documentation. You should prefer the template part version, because it is more flexible regarding the DOM structure. |
Fields
-
Value list: A reference to a BSI Suite value list. Mandatory.
-
Initial value: Optional initial value for the HTML form field. Only values belonging to the referenced Value list are available. Only editable if Value list is set.
| It is also possible to define an initial value within the configuration of a story, which supersedes the initial value of the content. |
basic-dynamic-value-list part.<div data-bsi-element="basic-dynamic-value-list" data-bsi-element-part="basic-dynamic-value-list" data-bsi-entity-id="">
<label>Field</label>
<input type="text" class="w-input dynamic-select" data-bsi-entity-key-value="" data-bsi-entity-key-display-text="">
</div>
Usage
<div data-bsi-element="dynamic-value-list" data-bsi-entity-id="{{context.dataModelValue.type}}" >
<input
data-bsi-entity-key-value="{{context.dataModelValue.value}}"
data-bsi-entity-key-display-text="{{context.displayText}}" >
</div>
The DOM structure is identical to the form-field element part.
The data-bsi-* attributes must be placed on the root DIV element and on the nested INPUT element, as shown in the example above.
Design.json
design.json file.{
"elementId": "basic-dynamic-value-list",
"file": "content-elements/forms/basic-dynamic-value-list.html",
"icon": "dropdown",
"label": "Dynamic Value List (Basic)",
"description": "Use dynamic source e.g. CRM",
"parts": [
{
"partId": "basic-dynamic-value-list",
"label": "Dynamic select"
}
]
}
link
The part is defined on the <a> element.
As an option, the link content can be set with the data-bsi-link-fixed-inner-html attribute.
If this attribute is present, only the href attribute of the link can be edited in the content editor.
If the link text is to be placed in a tag within the hyperlink (e.g. in a span next to an <img> tag), the optional data-bsi-link-text-part attribute can be set on the tag.
Boolean attributes like data-bsi-link-fixed-inner-html could require an empty value ="" or sample value like ="true".
|
<div data-bsi-element="cta" class="element cta">
<a href="https://www.bsi-software.com/" data-bsi-element-part="link">More</a>
</div>
data-bsi-link-fixed-inner-html.<div data-bsi-element="cta" class="element cta">
<a href="[dynamic_link]" data-bsi-element-part="link" data-bsi-link-fixed-inner-html>
<span>
<p> Some static content </p>
<p data-bsi-element-part="formatted-text"> Add your text here! </p>
</span>
</a>
</div>
data-bsi-link-text-part.<div data-bsi-element="cta">
<a data-bsi-element-part="link" href="#" role="button">
<i class="icon icon-028-arrow-back"></i>
<span data-bsi-link-text-part>The link text is </span>
</a>
</div>
social-follow
A <div> element, contains <div> elements with a data-bsi-social-follow attribute.
These attributes contain the value of the respective social media service, such as "Facebook", "Twitter", "Pinterest", etc.
The elements with data-bsi-social-follow must have the social-media-item class.
This class is used to manage the visibility of each individual social media channel in the editor.
The elements with data-bsi-social-follow must also contain an <a> element.
The link href can be preselected with a URL or with CX links in square brackets (e.g., [Facebook]).
The <a> element, in turn, can contain additional elements.
<div data-bsi-element="social-follow" data-bsi-element-part="social-follow">
<div data-bsi-social-follow="Facebook" class="social-media-item">
<a href="https://www.facebook.com/">
<img src="facebook.png" alt="Facebook" />
</a>
</div>
<div data-bsi-social-follow="Twitter" class="social-media-item">
<a href="https://www.twitter.com/">
<img src="twitter.png" alt="Twitter" />
</a>
</div>
</div>
social-share
A <div> element, contains <div> elements with data-bsi-social-share.
These attributes contain the value of the respective social media service, such as Facebook, Twitter, Pinterest, or even e-mail.
The elements with data-bsi-social-share must have the social-media-item class.
This class is used to control the visibility of each individual social media channel in the editor.
The elements with data-bsi-social-share must also contain an <a> element.
The link href can be preselected with a URL or with Studio links in square brackets (e.g., [Facebook]).
To share it via e-mail, the content of the href is then a mailto:?subject=(subject.with.title)&body=(description.with.url)
The <a> element, in turn, can contain additional elements.
The URL supports a list of wildcards that are specific to the social share part. When they are issued, all wildcards are automatically URL-encoded. These wildcards cannot be selected in the step configuration in Studio. The following wildcards exist:
| url |
The URL/internet address of the current Studio webpage or the user-defined URL. |
| description |
The description text of the current Studio webpage or the user-defined description text (a maximum of 300 characters). |
| description.short |
Same as description, but a maximum of 140 characters; all additional characters are truncated. |
| description.with.url |
Same as description; in addition, the url is added to the end of the description text. |
| title |
The title of the current Studio webpage or the user-defined title (a maximum of 100 characters). |
| title.with.url |
Same as title, and, in addition, the url is added to the end of the description text. |
| subject.with.title |
Same as title, and, in addition, a text "Share web-site:" is added to the beginning of the title; is used as the subject in an e-mail. |
| preview.image.url |
The URL/internet address for the preview image of the webpage according to the configuration in the content editor. |
<div data-bsi-element="social-share" data-bsi-element-part="social-share">
<div class="social-media-info">Share this page</div>
<div data-bsi-social-share="E-Mail" class="sm-email social-media-item share">
<a href="mailto:?subject=(subject.with.title)&body=(description.with.url)"></a>
</div>
<div data-bsi-social-share="Facebook" class="sm-facebook social-media-item share">
<a href="https://www.facebook.com/sharer/sharer.php?u=(url)" target="_blank"></a>
</div>
<div data-bsi-social-share="LinkedIn" class="sm-linkedin social-media-item share">
<a href="https://www.linkedin.com/shareArticle?mini=true&url=(url)&summary=(title)&source=FancyUnicorns" target="_blank"></a>
</div>
<div data-bsi-social-share="Pinterest" class="sm-pinterest social-media-item share">
<a href="http://pinterest.com/pin/create/button/?url=(url)&description=(title)&media=(preview.image.url)" target="_blank"></a>
</div>
<div data-bsi-social-share="Twitter" class="sm-twitter social-media-item share">
<a href="https://twitter.com/intent/tweet?url=(url)&text=(description.short)" target="_blank"></a>
</div>
<div data-bsi-social-share="WhatsApp" class="sm-whatsapp social-media-item share">
<a href="whatsapp://send?text=(title.with.url)" target="_blank"></a>
</div>
<div data-bsi-social-share="Xing" class="sm-xing social-media-item share">
<a href="https://www.xing.com/spi/shares/new?url=(url)" target="_blank"></a>
</div>
</div>
url-provider
Deprecated since release 25/2.
Instead, create a content element which defines the attribute data-bsi-url-provider
and uses a Handlebars plain-text template part to write the attribute value.
|
The URL provider content element part can be used to load dynamic data inside a story. Inside the content editor, the URL provider part only offers a text field to define its name. When using the content inside your story, each URL provider part will produce a separate outlet. This outlets can be connected to any URL provider (e.g. the Charts Step).
<div data-bsi-element="pie-chart" data-bsi-element-part="url-provider" class="mb-4 chart-js">
<img src="./pie-chart-placeholder.png" alt="" class="w-100" data-bsi-element-part="image"/>
</div>
When a story renders the content, the HTML tag with the url-provider part will have a data-bsi-url attribute.
This attribute will contain an absolute URL to the BSI CX server, where the data can be requested.
Using the Chart URL Provider
We created a small JavaScript library to use the chart URL provider in a template. Take a look at the repository on GitHub for more information. To integrate the library, install it with NPM:
npm install --save github:bsi-software/bsi-cx-chart#semver:^1.1.2
You also must install a chart library of your choice, currently there are only bindings for Chart.js. You can install it using npm:
npm install --save chart.js
Now, create your content element:
<div data-bsi-element="pie-chart" data-bsi-element-part="url-provider" class="chart-js">
<img src="./pie-chart-placeholder.png" alt="" class="w-100" data-bsi-element-part="image"/> (1)
</div>
| 1 | This will be replaced when the library is initialized, and the data from the URL provider is available. So it’s recommended to put some placeholders here. |
To use the library, you must initialize it:
import 'chart.js/auto'; (1)
import {ChartConfig, ChartUrlProvider} from '@bsi-cx/chart';
import ChartConfigColor from '@bsi-cx/chart/src/config/color';
/**
* @type {{border: ChartConfigColor, background: ChartConfigColor}[]}
*/
const colors = [
ChartConfigColor.of('#ff6384ff', '#ff638466'),
ChartConfigColor.of('#36a2ebff', '#36a2eb66'),
ChartConfigColor.of('#cc65feff', '#cc65fe66'),
ChartConfigColor.of('#ffce56ff', '#ffce5666')
]; (2)
const config = new ChartConfig()
.withColors(...colors);
document.querySelectorAll('.chart-js') (3)
.map(element => new ChartUrlProvider(element, config))
.forEach(chart => chart.render());
| 1 | Initialize the Chart.js library. |
| 2 | Optional, can be used to define your own set of colors. |
| 3 | Select all URL provider parts you want to initialize with the ChartUrlProvider. |
Template Parts
It is also possible to build content elements based on the Handlebars templating engine. For design developers this means that they have the choice of either building content elements using the HTML Element Parts described in the last chapter, or the new Handlebars Template Parts. Crucially it is not allowed to mix both in one content element.
Template Parts work in quite a different way from Element Parts: All they do is supply a part of the content element editor, as the name suggests. Each Template Part has a defined set of variables that it provides to render the content elements Handlebars template. A full example might look something like this:
design.json.{
"elementId": "medium-quote-hbs",
"type": "template-element",
"file": "content-elements/content/medium-quote-hbs.hbs",
"contextFile": "content-elements/content/medium-quote-hbs.json",
"icon": "heading",
"label": "Medium Quote",
"templateParts": [
{
"partId": "multiline-plain-text",
"partContextId": "text", (1)
"label": "Text"
},
{
"partId": "checkbox",
"partContextId": "italic", (2)
"label": "Text Kursiv anzeigen"
}
]
}
The content element consists of two Template Parts, crucially they have to be explicitly mentioned in the design.json, since - as opposed to the Element Parts they do not have an explicit declaration in the HTML DOM.
The first Template Part lets the user define a multiline text without any markup, the second exposes a boolean value, that in this example is used to set the text to italic, if the user checks the checkbox.
This results in the following content element editor:
The handlebars template and the default values are as follows:
<div class="content-element-wrap" data-bsi-element="medium-quote-hbs">
<div class="paragraph-light" {{#if italic.value}}style="font-style: italic"{{/if}}>{{text.value}}</div> (3)
</div>
{
"text": { (1)
"value": "Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua." (2)
},
"italic": { (1)
"value": false (2)
}
}
| 1 | The partContextId defines the name of the instance of the Template Part since there can be more than one of the same type. |
| 2 | Each Template Part supplies an object containing specified context variables that can be used to render the template. |
| 3 | The variable name is prefixed with the partContextId when it is referred to in the Handlebars template. |
Including Handlebars Content Elements in design.hbs
HTML content elements could be included in the design.html by copying the DOM from the content element source file into the body of the design.
Changes in the default value took place directly in the DOM of the design. Handlebars content elements work analogous.
The template from the content element source code can be copied into the design.hbs, but two additional steps are necessary.
Let’s take the example of a simple text paragraph content element.
The content element consists of a Handlebars template, and a variable context as such:
<div class="paragraph-light" data-bsi-element="paragraph">{{paragraph.value}}</div>
{
"paragraph": {
"value": "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."
}
}
After copying the Handlebars template to design.hbs, we need to supply the values for the variables contained in the element in design-context.json.
This is achieved by adding the custom attribute data-bsi-context-scope with a unique name for the element on content element.
All variables used within the element need to be prefixed with this unique name.
This unique name then also refers to the element in design-context.json:
design.hbs.<div class="paragraph-light" data-bsi-element="paragraph" data-bsi-context-scope="headingParagraph">{{headingParagraph.paragraph.value}}</div>
{
"headingParagraph": {
"paragraph": {
"value": "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."
}
}
}
plain-text
This template part supplies a text input field, into which the user can input a single line of plain text.
multiline-plain-text
This template part supplies a single multiline input field, into which the user can input plain text.
formatted-text
This template part closely mirrors the corresponding formatted-text element part.
It provides a configurable HTML WYSIWYG editor.
Since this part provides a variable with HTML code, you should use the 'triple-stash' syntax of Handlebars to output the variable: {{{textPart.html}}}.
Otherwise the HTML code would be escaped when the template is being rendered.
|
Editor
As with the corresponding element part, the toolbar of the editor can be configured using a htmlEditorConfig.
The picture shows the current default editor.
link
An template part that provides URL and accessibility information for a link.
Variables
-
url: The URL for the link.
-
text: The link text.
-
description: Accessibility information that describes the link for screen readers. This can be added to the
aria-labelattribute. -
openInNewWindow: Boolean value to describe where the link should be opened, can be used in conjunction with
target="_blank".
image
The image template part supplies all values needed to render an image in the content, including accessibility information.
Editor
The screenshot shows two possible configurations of the image template part editor:
- above
-
Alternative text is set to mandatory, the additional accessibility fields are visible.
- below
-
Alternative text is not mandatory and all accessibility fields are invisible.
The second configuration should only be used in very specific circumstances, e.g. multiple sources in a HTML <picture> tag.
Variables
-
altText: Accessibility-feature, alternative text that is also shown if the browser cannot show the picture.
-
srcUrl: The URL that points to the selected image.
-
placeholderSrcUrl: The URL pointing to a placeholder image (used for the content editor).
-
srcset: Srcset-String. Only relevant if sizes have been defined in the design.
-
decorative: Boolean value that can be used to set the accessibility option
aria-hidden="true", which results in screenreaders ignoring the image entirely.
Configuration
The template part can be configured with the following values:
-
altTextMandatory: Makes the alternative text field in the UI mandatory.
-
srcsetSizes: List of size definitions, as used in the
srcsetHTML attribute, see example below. -
hideAccessibilityFields: Hides all accessibility fields in the editor UI.
Example:
"config": {
"hideAccessibilityFields": true,
"altTextMandatory": false,
"srcsetSizes": [
"400w",
"800w",
"1200w"
]
}
checkbox
The checkbox template part is mainly used for control-structures in the Handlebars-template.
It supplies a simple checkbox element and a boolean value that can be used e.g. for {{#if}}-blocks within the content element.
option
The option template part is mainly used for control-structures in the Handlebars-template. It allows to define a list of key/value options in the design and provides the key of the option selected by the user in the content editor.
Since the {{#if}} blocks in Handlebars do not support logical expressions, the variable from the option part is usually used with the Handlebars helpers eq and neq. For example such as:
{{#eq imageCaptionOption.option "yes"}}
<div class="paragraph-light news-image-description">{{image.altText}}</div>
{{/eq}}
The negation works analogous, just using {{#neq a b}} instead of the {{#eq a b}} shown in the example above.
Configuration
The option template part needs one or more configured options that each consists of a value and a text that is displayed to the user in the editor user interface. In the Handlebars template, the value of the selected option is applied to the 'value' variable.
The template part configuration is structured as follows:
-
options: List of options consisting of:
-
text: Display text shown to the user in the content element editor
-
value: The value that is exposed in the variable context of the template part
-
Example:
"config": {
"options": [
{
"text": "Ja",
"value": "yes"
},
{
"text": "Nein",
"value": "no"
}
]
}
dynamic-value-list
This Handlebars template part offers functionality for the integration of BSI Suite value lists into any HTML form, providing REST endpoints for the purpose of retrieving values from such lists.
Variables
-
Value list: A reference to a BSI Suite value list. Mandatory.
-
Initial value: Optional initial value for the HTML form field. Only values belonging to the referenced Value list are available. Only editable if Value list is set.
| It is also possible to define an initial value within the configuration of a story, which supersedes the initial value of the content. |
Backend processing and HTML rendering
The BSI backend processes dynamic value lists in the following manner:
-
The BSI Suite value list is defined in the content using the content editor, and this value is stored in the BSI CX database.
-
During the rendering of the HTML, the ID of the value list is utilized to create a REST endpoint, and the URL of this endpoint is transmitted to and made available in the client’s DOM.
-
The endpoint is invoked by the client to retrieve all values of the value list.
-
The values are processed and transmitted to the BSI CX backend upon form submission, and these values can be utilized in BSI CX stories for further processing. The values automatically possess the correct BSI data model type.
Involved BSI HTML Attributes
-
data-bsi-entity-id: Holds a BSI datamodel entity ID (i.e., an ID referencing the BSI Suite value list). Only used at configuration time, not sent to clients.
-
data-bsi-entity-key-value: Holds an entity key belonging to the element’s data-bsi-entity-id. This value is used to set the form field’s initial value. Only used at configuration time, not sent to clients. The value of this attribute is symmetrically encrypted and set into the HTML element’s value attribute before the HTML is sent to any clients.
-
data-bsi-entity-key-display-text: Human readable label of the key stored in data-bsi-entity-key-value. This attribute is preserved and sent to clients.
-
data-bsi-rest-resource: Target endpoint to lookup values belonging to the element’s data-bsi-entity-id. This attribute is preserved and sent to clients.
Design integration
The integration process consists of two stages. Firstly, the BSI data model entity IDs and keys are set in the content during configuration time. Secondly, these values are retrieved when the HTML form is opened via REST during runtime.
Configuration time
The Handlebars template part’s editor persists the following context variables:
-
dataModelValue: A nested JSON holding the BSI datamodel type and (if set) initial value key.
-
displayText: The initial value key’s human-readable label. May be empty.
{
"dataModelValue": {
"type": "entity:1234",
"value": "entity:1234:key:9876"
},
"displayText": "I belong to key 9876"
}
To correctly encrypt and map BSI datamodel values, the BSI CX backend expects:
-
The HTML element tagged with dynamic-value-list also has to reference and set the BSI HTML attribute data-bsi-entity-id. data-bsi-entity-id is used to create the URL for the lookup-call.
-
The HTML input on the form has to reference the BSI HTML attribute data-bsi-entity-key-value. This enables default values.
<div data-bsi-element="dynamic-value-list" data-bsi-entity-id="{{context.dataModelValue.type}}" >
<input
data-bsi-entity-key-value="{{context.dataModelValue.value}}"
data-bsi-entity-key-display-text="{{context.displayText}}" >
</div>
Runtime
It is the frontend code’s responsibility to retrieve and display a value list’s values.
-
The element tagged with dynamic-value-list contains a REST endpoint to retrieve the values of the value list. It is exposed via the BSI HTML attribute data-bsi-rest-resource. The REST call uses the GET method and returns a JSON containing one attribute called options. This attribute holds a list of id-text pairs. The id is always encrypted.
-
Ensure that the correct encrypted id is sent to the BSI CX backend on a form submit.
-
The element marked with the tag "dynamic-value-list" contains a REST endpoint for retrieving the values of the value list, which is exposed via the BSI HTML attribute "data-bsi-rest-resource". The REST call utilizes the GET method and returns a JSON object containing a single attribute named "options", which holds a list of id-text pairs. The id is always encrypted.
-
It is essential to ensure that the correct encrypted id is transmitted to the BSI CX backend upon form submission.
<div data-bsi-rest-resource="http://your-client.bsi/inbound/default/r/bsi-code-rest-resource?entityId=WcaYlNlwe6VnI72" >
<input
value="kOi4pUb17YbVcvVlaU9-kiQW993"
data-bsi-entity-key-display-text="I belong to the encrypted key kOi4pUb17YbVcvVlaU9-kiQW993" >
</div>
{
"options": [
{
"id": "kOi4pUb17YbVcvVlaU9-kiQW993",
"text": "label 1"
},
{
"id": "mRt7xQe42NcBzxTpoL3-zvER581",
"text": "label 2"
},
{
"id": "fLn2vHd89JmTqyWkdA6-wuTY764",
"text": "label 3"
}
]
}
REST parameters
The REST endpoint exposed via data-bsi-rest-resource accepts the following query parameters:
-
entityId: The encrypted value list type. Mandatory. This parameter is provided by the BSI CX backend and already set. There is no need to adapt it in the frontend.
-
q: Query parameter. Optional. If set, it’s value is used to perform a case-insensitive prefix search on the lookup result’s texts. Only matching results are sent to the client.
-
lang: Requested language parameter. Optional. If set, the value is used to parse a JAVA locale. The locale is used to perform the lookup and returns the result in the corresponding language. It is recommended to set this attribute to the DOM’s language attribute (which is normally set via BSI CX’s content engine). If no value is provided, the request’s language (i.e., the client’s browser language) is used. The last fallback is the BSI CX backend’s system language. Example values: de-DE, de-CH, de, en, en-US, fr, …
http://your-client.bsi/inbound/default/r/bsi-code-rest-resource?entityId=WcaYlNlwe6VnI72&q=searchVal&lang=de
The REST endpoint made available via data-bsi-rest-resource supports the following query parameters:
-
entityId: The encrypted value list type. Mandatory. This parameter is provided by the BSI CX backend and is already set, therefore no adjustments are necessary in the frontend.
-
q: Query parameter. Optional. If specified, its value is utilized to perform a case-insensitive prefix search on the lookup result’s texts. Only matching results are transmitted to the client.
-
lang: Requested language parameter. Optional. If specified, the value is used to parse a JAVA locale. The locale is then used to perform the lookup and return the result in the corresponding language. It is recommended to set this attribute to the DOM’s language attribute, which is typically set via BSI CX’s content engine. If no value is provided, the request’s language (i.e., the client’s browser language) is used. The last fallback is the BSI CX backend’s system language. Example values include de-DE, de-CH, de, en, en-US, fr, etc.
How to create a content element using the value list part
The element is based on the new Handlebars integration in BSI CX designs. To work properly with the BSI CX form engine, your element should also contain two additional template element parts:
-
id: A plain-text Handlebars template part to uniquely identify the form field in a form. Ensure that the HTML form field’s ID attribute is set to this value. Mandatory.
-
name: The form field’s label. Mandatory.
Minimal example implementation
{
"id": {
"value": "dynamic-dropdown-1"
},
"name": {
"value": "Field"
},
"entityTypeAndInitialValue": {
"dataModelValue": {
"type": "",
"value": ""
},
"displayText": ""
}
}
<div data-bsi-element="dynamic-value-list" data-bsi-entity-id="{{entityTypeAndInitialValue.dataModelValue.type}}" >
<label for="{{id.value}}">{{name.value}}</label>
<input id="{{id.value}}" name="{{id.value}}"
value="{{entityTypeAndInitialValue.displayText}}"
data-bsi-entity-key-value="{{entityTypeAndInitialValue.dataModelValue.value}}"
data-bsi-entity-key-display-text="{{entityTypeAndInitialValue.displayText}}" >
</div>
{
"contentElements": [
{
"elementId": "example-dynamic-value-list",
"type": "template-element",
"file": "path/to/my-example.hbs",
"contextFile": "path/to/my-example.json",
"label": "Dynamic select",
"templateParts": [
{
"partId": "plain-text",
"partContextId": "id",
"label": "ID"
},
{
"partId": "plain-text",
"partContextId": "name",
"label": "Field name"
},
{
"partId": "dynamic-value-list",
"partContextId": "entityTypeAndInitialValue",
"label": "Value list"
}
]
}
]
}
The code snippets above represent the HTML component. A possible method for invoking the REST endpoint is provided in the snippet below.
let $valueListElem = findValueListElement(); // Frontend code's responsibility
let dataSourceUrl = $valueListElem.attr('data-bsi-rest-resource');
fetch(dataSourceUrl, {
method: "GET",
body: new URLSearchParams({
q: getQueryParam($valueListElem), // Frontend code's responsibility
lang: document.documentElement.lang })
})
.then(response => {
// ... Frontend code's responsibility
});
If you want to implement a dropdown including autocompletion, you may consider JQuery UI as a starting point.