Conditional Elements Introduction

Conditional Elements allow Administrators and Power Users to customize the Content Editing Experience for their users by conditionally displaying elements based on specific criteria. This feature helps simplify and streamline the content creation process for users by showing only relevant fields to Content Editors.

Conditional Statement Types

There are three types of conditional statements; 

Content Element-Based Conditions, User Group Conditions, and User Type Conditions.

1. Content Element-Based Conditions

  • Allows element(s) to be shown based on the content of a different element.
  • Useful for revealing additional elements based on specific input.

Example 1: "If 'Research Type' is set to 'Grant-Funded', then show 'Funding Body Details' field"

Example 2: "If 'Course Level' dropdown is 'Postgraduate', then show 'Research Methodology' field"

Options depending on element type

Depending on the type of element you select, the options available for your conditional statements may be different.

The table below outlines all the different options depending on the element type selected.

Element Type Conditions Available Option Available (If applicable)
Plain Text
  • Is Empty
  • Is not Empty
  • Contains
  • Does not contain

If the Condition is set to "Contains" or "Does not contain":

User is shown a text input where they can type a string

HTML
  • Is Empty
  • Is not Empty
  • Contains
  • Does not contain

If the Condition is set to "Contains" or "Does not contain":

User is shown a text input where they can type a string

Date
  • Is Empty
  • Is not Empty

N/A

Decimal Number
  • Is Empty
  • Is not Empty

N/A

Whole Number
  • Is Empty
  • Is not Empty

N/A

Media
  • Is Empty
  • Is not Empty

N/A

File
  • Is Empty
  • Is not Empty

N/A

Image
  • Is Empty
  • Is not Empty

N/A

Select Box
  • Is Empty
  • Is not Empty
  • Contains
  • Does not contain

If the Condition is set to "Contains" or "Does not contain":

User is shown dropdown input where they can select a single value from the selected list

Check Box
  • Is Empty
  • Is not Empty
  • Contains
  • Does not contain

If the Condition is set to "Contains" or "Does not contain":

User is shown dropdown input where they can select a single value from the selected list

Radio Button
  • Is Empty
  • Is not Empty
  • Contains
  • Does not contain

If the Condition is set to "Contains" or "Does not contain":

User is shown dropdown input where they can select a single value from the selected list

Multi-select List
  • Is Empty
  • Is not Empty
  • Contains
  • Does not contain

If the Condition is set to "Contains" or "Does not contain":

User is shown dropdown input where they can select a single value from the selected list

Multiple Select
  • Is Empty
  • Is not Empty
  • Contains
  • Does not contain

If the Condition is set to "Contains" or "Does not contain":

User is shown dropdown input where they can select a single value from the selected list

Cascading List
  • Is Empty
  • Is not Empty
  • Contains
  • Does not contain

If the Condition is set to "Contains" or "Does not contain":

User is shown dropdown input where they can select a single value from the selected list

Keyword Selector
  • Is Empty
  • Is not Empty

N/A

Section/Content Link
  • Is Empty
  • Is not Empty

N/A

Content Owner
  • Is Empty
  • Is not Empty

N/A

Group Select
  • Is Empty
  • Is not Empty

N/A

2. User Group Conditions

Allows showing/hiding elements based on user group membership.

Example 1: "If User is in group 'International Admissions', then show 'Visa Requirements' elements"

Example 2: "If User is in group 'Research Grants Team', then show 'Indirect Cost Calculation' element"

3. User Type Conditions

  • Controls element visibility based on the user's permission level
  • Helps manage element access for different user types (Administrator, Power User, Moderator, Contributor)
  • Simplifies content creation UI for user types that may not need to see all elements

Example 1: "If User is at least 'Administrator', then show 'Advanced Options' element"

Example 2: "If User is at least 'Moderator', then show 'Background Image' element"

Important Considerations

Logic Rules

  • All conditional statements use OR logic
  • If ANY conditional statement indicates an element should be displayed, it will be shown
  • Note: Currently, AND logic is not supported
    • For example, it's not possible currently to create a rule like "If 'Element A' contains 'Test' AND 'Element B' contains 'Test' Then show 'Element C'.

Scope of Functionality

Editing Experience Only

  • Conditional Elements ONLY affect how elements are displayed to Content Editors.
  • This feature does NOT impact how content is output on published pages.
Content Layouts may require separate configuration for output logic.

Not a Security Feature

  • Conditional Elements is a quality of life improvement.
  • Hidden elements can still potentially be accessed or edited.
Do NOT rely on this feature for access control or security purposes.

Not Supported on System Content Types

Power User Permissions

Power Users do have the ability to manage Content Types for any groups they are a member of.

This means that Power Users can create and edit existing Conditional Statements.

Important Note User Group-Based Conditions

  • If an already existing Conditional Statement specifies an element should be shown only to users in a specific group
  • AND the Power User is NOT a member of that group
  • THEN the Power User will be prevented from:
    • Modifying that existing Conditional Statement
    • Removing that existing Conditional Statement
  • Power Users can safely modify other conditional statements and add new ones

In the scenario that a Power User needs to remove or modify a Conditional Statement that they do not have access to, it is recommended that they

  • Consult an Admin to make the change for them OR
  • Request temporary access to the required group from an Admin

Required Fields

  • If an element is marked as "required" but it is hidden by a conditional statement, it is NOT considered required.
  • "Required" now means "required if shown to content editors".

Saving Content with hidden fields

When saving content items, the data within hidden elements is NOT changed from how it was stored when the content is first loaded.

  • If a user edits a content item and a field is hidden, the data in that field isn’t removed when saving
  • If a user edits a content item and makes a change that results in a previously displayed element to become hidden, the value of the now hidden field remains unchanged when saving
  • If a user edits a content item and changes a value in "Field A" and then that user subsequently makes a change that results in "Field A" being hidden, when the content item is saved, the changes in "Field A" will not be saved

If adding conditional statements to existing Content Types it is advised that you consider whether logic is also required in your Content Layouts to ensure the expected data is output.

Debugging Conditional Elements

Reveal Hidden Elements Option

When an Admin (or a Power User with the permissions to edit the Content Type) edits a content item with Conditional Elements:

  • A new "Reveal hidden elements" checkbox is available
  • When checked, ALL conditional logic is temporarily disabled
  • All elements are displayed, regardless of existing conditions

This option is there to help administrators troubleshoot cases where elements are hidden and it's not clear why.

How to Configure Conditional Elements

There are three types of conditional statements that can be used:

Content Element-Based Conditions

  • e.g. If an 'Image' is added to a news item, then show 'Image Caption' element.
  • e.g. If 'Research Type' is set to 'Grant-Funded', then show 'Funding Body Details' element.
  • e.g. If 'Course Level' dropdown is 'Postgraduate', then show 'Research Methodology' element.

User Group Conditions

  • e.g. If User is in group 'Marketing & Communications', then show 'Feature News on Homepage' element.
  • e.g. If User is in group 'International Admissions', then show 'Visa Requirements' elements.
  • e.g. If User is in group 'Research Grants Team', then show 'Indirect Cost Calculation' element.

User Type Conditions

  • e.g. If User is at least 'Administrator', then show 'Advanced Options' element.
  • e.g. If User is at least 'Moderator', then show 'Background Image' element.

Accessing Conditional Logic

  • Navigate to a Content Type (Assets > Content Types) and select a Content Type
  • Select the "Elements" tab
  • Click on the "Conditional logic" button

Screenshot of user interface of Content Types' Elements tab highlighting the location of the Conditional logic button at the top right and bottom right of the screen

This opens a slide-out window where you can create conditional statements and view a real-time preview.

Real-Time Preview

When configuring Conditional Elements, you'll notice:

  • A live preview of the content item is automatically displayed.
  • The preview updates in real time as you add or modify conditional statements.
  • You can immediately see how your logic affects the editing interface.

Saving changes

Once you've created your conditional statements, ensure you save the Content Type before navigating away from the page.

Conditional elements in News Content Type

In the News Content Type you created earlier, some elements are optional, allowing content editors to decide whether they should be populated.

One example is the Image Caption element. While it is optional, it should only be completed when an image has been added. Relying on editors to remember this can lead to inconsistent content and accessibility issues.

Another example is to use the Groups condition to only allow members of specific groups access to an element that will have the news item "feature" on your home page.

Conditional Elements allow you to control when elements are displayed and whether they are required, based on the values of other elements. This helps enforce editorial standards, improve content quality, and simplify the editing experience by showing only the fields that are relevant.

In the following exercise, you'll configure the Image Caption element so that it is displayed and becomes mandatory only when the preceding Image element has been populated.

How to configure your Image Caption using "Content Element" conditional logic

  1. Go to Assets > Content Types
  2. Click into your News Content Type to open it for editing. (Use the Filter tool to locate it if needed.)
  3. Go to the Elements tab
  4. Click Conditional logic, a conditional logic window will slide out.
  5. Click Add conditional statement and build the following statement:
    1. If: Content Element
    2. Image (Media)
    3. Is not empty
    4. Then show: Image caption
      If wanted, you can make the Image Caption element a required/mandatory element

    5. Click Apply and close, you will be returned to the Elements tab
    6. Click Save changes to save your work.

Screenshot of a Conditional statement for News Image Caption

How to configure a "Feature on Homepage" element using "User is in Group" conditional logic

  1. Go to Assets > Content Types
  2. Click into your News Content Type to open it for editing. (Use the Filter tool to locate it if needed.)
  3. Go to the Elements tab
  4. Click Conditional logic, a conditional logic window will slide out.
  5. Click Add conditional statement and build the following statement:
    1. If: User is in group
    2. Select your group i.e., Marketing & Communications
    3. Then show: Feature on Homepage?
    4. Click Apply and close, you will be returned to the Elements tab
    5. Click Save changes to save your work.

Links Content Type

In this exercise, you will learn how to create a Links Content Type that incorporates conditional elements. Using conditional elements improves the content editing experience by displaying only the fields that are relevant based on the editor's selections, making the interface more intuitive and efficient.

How to create the "Links" Content Type

  1. Go to Assets > Content Types > Create content type
  2. Fill in the General Content Type information:
    1. Name: enter a name here. This should suggest what type of content it is used for.
    2. Description: describe in more detail when to use this Content Type.
    3. Minimum user level: if you wish to restrict who can use this Content Type, you can set a level here. If Content Types are created in groups, a user must be a member of the group as well as meet the minimum user level criteria to use the Content Type.
    4. Enable direct edit: decide if direct edit can be used for this Content Type.
    5. Mark as eForm: if checked, this allows your Content Type to collect eForm data.
    6. Workflow: if relevant, enable a workflow for content created using this Content Type.
    7. Primary group: select your group. This allows you to select the group which is permitted to use this Content Type. Click Toggle shared groups to share the Content Type with more than one group.
  3. Select the Elements tab.
    1. Each Content Type has a Name element by default. This is used to name the content and is typically not displayed on the published site.
    2. Add the other elements you need by filling in the information as outlined in the table below. Click Add element to begin filling in the details for each element.
    3. Once you have added all your elements, click Save changes. The Content Layout tab opens.
Name Description Type Max Size Required Show
Link Text Enter the text to appear on the link. E.g. “Learn More”. Plain Text 80 Yes Yes
Link (internal) Select a section/content for an internal link. Section/Content Link 80 Yes Yes
Link (external) Select this if you are entering a link to an external website. Plain Text 200 Yes Yes
Link (media) Select this if you’d like to link to a PDF. Media 80 Yes Yes
  1. The Content Layout tab is a new content layout for your Content Type. Click +Add content layout.
    1. Name: text/html - this is the default Type set in the Channel. This ensures the content can be displayed.
    2. File Extension: Default - unless this is used with a different File Extension. This requires other extensions being permitted in the Channel
    3. Syntax Type: HTML/XML – this determines which syntax is highlighted.
    4. Content layout processor: must be set to Handlebars Content.
    5. Content Layout code: this determines the output for your content. 

In the content layout, you need to output three different types of links: internal, external, and PDF links.

  • Internal link: Use the Link Helper to generate the URL. How to use the link Helper
  • External link: Set the href attribute to the value of the Link (external) field.
  • PDF link: Use the Media Helper to generate the href attribute. Be sure to use the path/* layout when generating the media URL.

{{#link element="Link (internal)"}}
     <p><a style="display: block" class="button small radius" href="{{linkUrl}}">{{publish element="Link Text"}}</a></p>
{{/link}}   

<p><a style="display: block" class="button small radius" href="{{publish element="Link (external)"}}">{{publish element="Link Text"}}</a></p>


<p><a style="display: block" class="button small radius" href="{{{media id=(mediaId element="Link (media)") layout="path/*"}}}">{{publish element="Link Text"}}</a></p>

  1. Click Save changes to save the changes to your content layout.
  2. Enable the Content Type in one of your sections, then create a Links content item to test its functionality and verify that it displays correctly on the page.

Lets now enhance the Content Type by adding a new element (Link Type) that will allow a content editor to select which type of link is being created.

How to create a list

  • Begin by creating a list that will populate the Link Type element. This list will be used as the source for a Select field, allowing users to choose the type of link they want to create. The available options are Internal, External, and PDF.
  1. Go to Assets > Lists > Add new list
  2. Fill in the List information:
    1. Name: enter a name here. This should suggest what type of list it is used for.
    2. Description: describe in more detail when to use this list.
    3. Localization:  if the List is available in more than one language, you can use the localization options to:
      1. checkbox: Use current language version of this list (This prevents translations of the list).
      2. checkbox: Only use this list when localized versions are not available (when no translation of the List exists, this List is used).
    4. Primary group: select your group. This allows you to select the group which is permitted to use this list. Click Toggle shared groups to share the list with more than one group.
  3. List items: enter the individual list items by clicking on the Add row button:
    1. Order: list items can be re-ordered using the move icon 
    2. Name: the name of the list item
    3. Value: the value of the list item
    4. Selected: when checked, this item will be the default selected item in the Content Type Element.
    5. Sublist: list items may have sub-categories that you want to link them to. Sublists are used with Cascading and Multi-select Content Type Elements.
Name Value Selected Sublist
Internal Link internal leave blank
External Link external leave blank
Media/PDF Link pdf leave blank
  1. Click on the Save changes button to save your list.
  2. Add the following new element to the Content Type (Link Type):
Name Description Type Max Size Required Show
Link Type Select which kind of link you’d like to use. Select Box (Link Type) 80 Yes Yes

You will make use of the selectedValues Helper and the eq comparison Helper. In this particular example, you will use the eq comparison Helper to compare the value in the "Link Type" list which can be "internal", "external" or "pdf" and display the correct link based on what is selected in the content.

There are a number of Helpers to allow you to compare values:
eq - Tests if two values are equal
neq - Tests if two values are not equal
gt - Tests if one value is greater than another
gte - Tests if one value is greater than or equal to another
lt - Tests if one value is less than another
lte - Tests if one value is less than or equal to another
and - Tests if values are true (you can pass two or more arguments)
or - Tests if any values are true (you can pass two or more arguments)
not - If the provided input is false then the block will not be processed

Arguments are space separated when passed to Handlebars expressions (as opposed to comma separated).

{{#eq (publish element="Greeting") "Hello"}}
    <p>Hello to you too!</p>
{{else}}
    <p>You didn't say "Hello".</p>
{{/eq}}

{{#lt 5 8}}
    <p>5 is indeed less than 8.</p>
{{else}}
    <p>This will never be published because 5 is always less than 8.</p>
{{/lt}} 

  1. Click into the Content layout code tab.
  2. Click on the </> Generate Handlebars Expression button.
  3. Open the </> Misc tab.
  4. In the Helpers drop-down, select the eq Helper.
  5. Click on Copy to clipboard to copy the generated Handlebars code. 
  6. Paste the Handlebars code into your content layout.

The code generated by the Handlebars expression builder should look like the code below:

{{#eq value1 value2}}
  value1 and value2 are equal
{{else}}
  value1 and value2 are not equal
{{/eq}}
Handlebars expression for eq Helper

  1. Update the code to match your requirements. Create three separate eq Helper blocks — one for each link type: "internal", "external", and "pdf". The Handlebars expressions for each link type are shown below. Note that the selected value from the “Link Type” list is compared against the three possible options using the selectedValues Helper. Copy the code into your layout.

{{#eq (selectedValues element="Link Type") "internal"}}
   
{{/eq}}

{{#eq (selectedValues element="Link Type") "external"}}
  
{{/eq}}

{{#eq (selectedValues element="Link Type") "pdf"}}
  
{{/eq}}

Next, create the appropriate output for each link type inside its corresponding Helper block. You can use the Handlebars expression builder to generate the required expressions.

  1. Click on the </> Generate Handlebars Expression button.
  2. In the Content tab:
    1. Information to output (select the Element radio button)
      1. Element: The Element option is used to output elements to the page.
      2. Metadata: The Metadata option allows output of specific Metadata (HTML anchor, Content ID, Last Modified Date, Publish Date, etc.).
      3. Fulltext: Used to output a fulltext link.
    2. Content element: Select the "Link (internal)" element from the content element drop-down.
    3. Handlebars helper: Choose Link from the drop-down.
    4. Options:
      1.   Convert special characters to their HTML encoded values This is disabled by default as links are not HTML encoded.
      2. Allow this element to be edited inline in Direct Edit This is disabled by default as list elements are not editable inline in Direct Edit.
      3. Check if value is set This option will wrap the element with an ifSet Helper. It ensures the element outputs only if it contains data.
  3. Click Copy to clipboard and paste in the Handlebars expression into the body of the Link (internal) eq block.
  4. Repeat the steps above for the Link (external) and Link (media) elements.
  5. Update the code as per below with the correct output for each type of link:

{{#eq (selectedValues element="Link Type") "internal"}}
   {{#link element="Link (internal)"}}
     <p><a style="display: block" class="button small radius" href="{{linkUrl}}">{{publish element="Link Text"}}</a></p>
   {{/link}}
{{/eq}}
{{#eq (selectedValues element="Link Type") "external"}}
  <p><a style="display: block" class="button small radius" href="{{publish element="Link (external)"}}">{{publish element="Link Text"}}</a></p>
{{/eq}}
{{#eq (selectedValues element="Link Type") "pdf"}}
  <a style="display: block" class="button small radius" href="{{{media id=(mediaId element="Link (media)") layout="path/*"}}}">{{publish element="Link Text"}}</a>
{{/eq}}

  1. Click Save changes to save the changes to your content layout.

Let's now add the following Content Element-Based Conditions to the Content Type:

  1. If 'Link Type' is set to 'Internal Link' then show 'Link (internal)' field
  2. If 'Link Type' is set to 'External Link' then show 'Link (external)' field
  3. If 'Link Type' is set to 'Media/PDF Link' then show 'Link (media)' field
  1. Go to Assets > Content Types
  2. Click your Content Type name to edit it. (Use the Filter tool to search). 
  3. Open the Elements tab.
  4. Click on the Conditional logic button to bring up the Conditional logic & Live Preview screen.
  5. Click on the +Add conditional statement button. Build a conditional statement for the "Internal Link" as per the table below:
Conditional Statement Element Column 3 Value Then show
Content Element Link Type (Select Box) Contains Internal Link Link (internal)

Conditional logic & Live Preview (Internal Link)

  1. Click on the +Add conditional statement button. Build a conditional statement for the "External Link" as per the table below:
Conditional Statement Element Column 3 Value Then show
Content Element Link Type (Select Box) Contains External Link Link (external)

Conditional logic & Live Preview (External Link)

  1. Click on +Add conditional statement button. Build a conditional statement for the "Media Link" as per the table below:
Conditional Statement Element Column 3 Value Then show
Content Element Link Type (Select Box) Contains Media/PDF Link Link (media)

Conditional logic & Live Preview (Media Link)

  1. Click on the Apply and close button to apply your conditional elements to the Content Type.
  2. Click Save changes to save your Content Type.

Individual Card Content Type

  • Repeaters allow you to configure a Content Type so that it can include another Content Type inside it. This allows for the easy creation of Content Types that are made of repeated elements, such as:
    1. Carousels and sliders
    2. Accordions and tabbed content
    3. Card rows and feature blocks
    4. FAQs and more
  • In this section, you will create a new "Individual Card" Content Type. As part of this process, you will use several new Helpers to display the content for each individual card on the page.

  • Next, you will use repeaters to output multiple "Card" Content Type items. To enable this, the "Individual Card" Content Type will be added as a repeater element within the "Card Section" Content Type.

How to create the "Individual Card" Content Type

  1. Go to Assets > Content Types > Create content type
  2. Fill in the General Content Type information:
    1. Name: enter a name here. This should suggest what type of content it is used for.
    2. Description: describe in more detail when to use this Content Type.
    3. Minimum user level: if you wish to restrict who can use this Content Type, you can set a level here. If Content Types are created in groups, a user must be a member of the group as well as meet the minimum user level criteria to use the Content Type.
    4. Enable direct edit: decide if direct edit can be used for this Content Type.
    5. Mark as eForm: if checked, this allows your Content Type to collect eForm data.
    6. Workflow: if relevant, enable a workflow for content created using this Content Type.
    7. Primary group: select your group. This allows you to select the group which is permitted to use this Content Type. Click Toggle shared groups to share the content type with more than one group.
  3. Select the Elements tab.
    1. Each Content Type has a Name element by default. 
    2. Add the other elements you need by filling in the information as outlined in the table below. Click Add element to begin filling in the details for each element.
    3. Once you have added all your elements, click Save changes. The Content Layout tab opens.
Name Description Type Max Size Required Show
Card Title Enter a title for the Card Plain Text 80 Yes Yes
Card Image Select an Image to be output on the card Media 80 No Yes
Card Content Some simple overview for the card HTML 8000 Yes Yes
Call To Action Choose where the card should link the user Section/Content Link 80 No Yes

How to create the "text/card-item" content layout

The next step is to create the text/card-item content layout that will define the output of the content of each individual card.

  1. The Content Layout tab is a new content layout for your Content Type. Click +Add content layout.
    1. Name: text/card-item - this is the name of the content layout for an individual card-item.
    2. File Extension: Default - unless this is used with a different File Extension. This requires other extensions being permitted in the Channel
    3. Syntax Type: HTML/XML – this determines which syntax is highlighted.
    4. Content layout processor: must be set to Handlebars Content.
    5. Content Layout code: this determines the output for your content. 
  2. Complete the TODOs below to create your content layout: 
    1. Write a Handlebars expression to output the src of the card image. (HINT: Make sure to select the "path/*" as the layout).
    2. Write a Handlebars expression to output the card title inside the h3 headline.
    3. Write a Handlebars expression to output the Card Content.
    4. Write a Handlebars expression to output the "Call To Action" link. (HINT: Use the link Helper).
      Click here to view the solution:

      <div class="card">
        {{#ifSet element="Card Image"}}
        <div class="card-image">
          {{!--1. TODO: Write a Handlebars expression to output the src of the card image (HINT: Make sure to select "path/*" as the layout).--}}
          <img src="{{{media id=(mediaId element="Card Image") layout="path/*"}}}" class="card-image"/>
        </div>
        {{/ifSet}}
        {{!--2. TODO: Write a Handlebars expression to output the "Card Title" inside the h3 headline.--}}
        <h3>{{publish element="Card Title" inline-edit="true"}}</h3>
        <div class="card-content">
          {{!--3. TODO: Write a Handlebars expression to output the Card Content.--}}
          {{{publish element="Card Content" inline-edit="true"}}}
        </div>
        {{!--4. TODO: Write a Handlebars expression to output the "Call To Action" link. (HINT: Use the link Helper).--}}
        {{#link element="Call To Action"}}
          <a href="{{linkUrl}}" class="card-cta">{{linkText}}</a>
        {{/link}}  
      </div>

<div class="card">
  {{#ifSet element="Card Image"}}
  <div class="card-image">
    {{!--1. TODO: Write a Handlebars expression to output the src of the card image (HINT: Make sure to select "path/*" as the layout).--}}
    <img src="" class="card-image"/>
  </div>
  {{/ifSet}}
  {{!--2. TODO: Write a Handlebars expression to output the "Card Title" inside the h3 headline.--}}
  <h3></h3>
  <div class="card-content">
    {{!--3. TODO: Write a Handlebars expression to output the Card Content.--}}
  </div>
  {{!--4. TODO: Write a Handlebars expression to output the "Call To Action" link. (HINT: Use the link Helper).--}}
  <a href="" class="card-cta"></a>
</div>

  1. Click Save changes to save the changes to your content layout.

How to create the "text/html" content layout for the Card Content Type

  1. The Content Layout tab is a new content layout for your Content Type. Click +Add content layout.
    1. Name: text/html - this is the default Type set in the Channel. This ensures the content can be displayed.
    2. File Extension: Default - unless this is used with a different File Extension. This requires other extensions being permitted in the Channel
    3. Syntax Type: HTML/XML – this determines which syntax is highlighted.
    4. Content layout processor: must be set to Handlebars Content.
    5. Content Layout code: this determines the output for your content. 

You will make use of the firstInSequence and lastInSequence Helpers in this content layout. These Helpers will allow you to output the opening and closing tags for each individual card section as needed.

first and last Helpers

The first Helper will be true when the content item is the first piece of content in a section.

{{#first}}
   <h1>First content item in the section</h1>
{{/first}}
The last Helper will be true when the content item is the last piece of content in a section.

{{#last}}
   <footer>Last content item in the section</footer>
{{/last}}

firstOfType and lastOfType Helpers

These Helpers let you know if an item of content is the first and last of its type in a section:

{{#firstOfType}}
  Only output if first of this Content Type in section
{{/firstOfType}}
{{#lastOfType}}
  Only output if last of this Content Type in section}}
{{/lastOfType}}

firstInSequence and lastInSequence Helpers

Perhaps more flexible though, are these Helpers which allow you to determine if an item of content is the first and last of its type in an uninterrupted sequence of content in a section.

The firstInSequence Helper will be true when the content item is the first piece of content using this Content Type in an uninterrupted sequence of content in a section.

{{#firstInSequence}}
  Only output if first of this Content Type in an uninterrupted sequence in this section
{{/firstInSequence}}

The lastInSequence Helper will be true when the content item is the last piece of content using this Content Type in an uninterrupted sequence of content in a section.

{{#lastInSequence}}
  Only output if last of this Content Type in an uninterrupted sequence in this section
{{/lastInSequence}}

Let's now demonstrate the use of these Helpers inside of the "text/html" content layout.

  1. Complete the TODOs below to create your content layout:
    1. Use the "firstInSequence" Helper to output the opening section tag. 
    2. Use the ember Helper to embed the "text/card-item" layout.
    3. Use the "lastInSequence" Helper to output the closing section tag. 
      Click here to view the solution:

      {{!--1. TODO: Use the "firstInSequence" Helper to output the opening section tag.--}}
      {{#firstInSequence}}
        <section class="card-group-section">
      {{/firstInSequence}}
      <div class="card-group-content-container">
        {{!--2. TODO: Use the embed Helper to embed the "text/card-item" layout.--}}
        {{embed layout="text/card-item"}}
      </div>
      {{!--3. TODO: Use the "lastInSequence" Helper to output the closing section tag.--}}
      {{#lastInSequence}}
        </section>
      {{/lastInSequence}}

{{!--1. TODO: Use the "firstInSequence" Helper to output the opening section tag.--}}
<section class="card-group-section">
<div class="card-group-content-container">
  {{!--2. TODO: Use the embed Helper to embed the "text/card-item" layout.--}}
</div>
{{!--3. TODO: Use the "lastInSequence" Helper to output the closing section tag.--}}
</section>

  1. Click Save changes to save the changes to your content layout.
  2. Enable the Card Content Type.
  3. In the Home section, create a Card Item and use it to test the newly created Content Type.

Use meaningful names that describe the content or purpose of each element. Avoid generic names like "Link 1" or "Card 1", as these can cause confusion when elements are reordered and repeaters are minimized.

Card Section Content Type

  • In this exercise, you will use a repeater element to display Card items on the page. You will also learn how to customize the repeater's output by using Handlebars code.

How to create the "Card Section" Content Type

  1. Go to Assets > Content Types > Create content type
  2. Fill in the General Content Type information:
    1. Name: enter a name here. This should suggest what type of content it is used for.
    2. Description: describe in more detail when to use this Content Type.
    3. Minimum user level: if you wish to restrict who can use this Content Type, you can set a level here. If Content Types are created in groups, a user must be a member of the group as well as meet the minimum user level criteria to use the Content Type.
    4. Enable direct edit: decide if direct edit can be used for this Content Type.
    5. Mark as eForm: if checked, this allows your content type to collect eForm data.
    6. Workflow: if relevant, enable a workflow for content created using this Content Type.
    7. Primary group: select your group. This allows you to select the group which is permitted to use this Content Type. Click Toggle shared groups to share the Content Type with more than one group.
  3. Select the Elements tab.
    1. Each Content Type has a Name element by default. You will use the Name element to output the Card's title.
    2. Add the other elements you need by filling in the information as outlined in the table below. Click Add element to begin filling in the details for each element.
Name Description Type Max Size Required Show
Name The Name element Plain Text 80 Yes Yes
Card Group Header Enter text for the header to be displayed above the Card Group Plain Text 200 Yes Yes
Card Group Introduction Enter text to be displayed before the Cards HTML 5000 Yes Yes
Card Individual Card Content Repeater: Individual Card     Yes

How to configure a repeater element

Notice that when selecting "Repeater" as the type for the Card element, a new "Flyout screen" will be displayed automatically that allows you to choose which Content Type should be repeated.

  1. Configure the repeater:
    1. Content type: select the Content Type to be repeated, this should be the name of your "Individual Card" Content Type.
    2. Content layout: the default layout that will be output for this repeater element, e.g. text/card-item.
    3. Repeater settings:
      1. Minimum repeats: the minimum amount of repeats allowed, e.g. 1.
      2. Maximum repeats: the maximum amount of repeats allowed, e.g. 5.
  2. Once you have finished configuring your repeater element, click Save changes.
  3. Once you have added all your elements, click Save changes. The Content Layout tab opens.

Configure repeater

How to create the "text/html" content layout

  1. The Content Layout tab is a new content layout for your Content Type. Click +Add content layout.
    1. Name: text/html - this is the default Type set in the Channel. This ensures the content can be displayed.
    2. File Extension: Default - unless this is used with a different File Extension. This requires other extensions being permitted in the Channel
    3. Syntax Type: HTML/XML – this determines which syntax is highlighted.
    4. Content layout processor: must be set to Handlebars Content.
    5. Content Layout code: this determines the output for your content. 

In this content layout you will use the repeater Helper to output the repeater element and you will be making use of the @first and @length variables.

The Repeater Helper is used to render a Repeater element, which was introduced in version 8.4.1.

By default, when a Repeater element is rendered using the Publish Helper, it uses the default Content Layout defined in the repeater's configuration.

If you need to specify a different Content Layout, use the Repeater Helper. This allows you to explicitly select the layout to render, as shown in the following example:

{{repeater element="Card" layout="text/card-item"}}

By combining the Each Helper with the Repeater Helper, you can iterate through each repeater item, access its variables, and gain greater control over how the repeater content is rendered.

For example:

{{#each (repeater element="Repeater Content Element")}}
    <p>Output</p>
{{/each}}

In this example, the <p>Output</p> block is rendered once for each repeater item. For instance, if the repeater contains five slides, the word Output will be rendered five times—once for each slide.

Because we're inside an each block, we have several variables available to us:

  • @length - this will return a number corresponding to how many repeated items there are in this element.
  • @first - true if this is the first repeater instance being output
  • @last - true if this is the last repeater instance being output
  • @odd - true if this this repeater instance has an odd index. Note that the array is zero-indexed.
  • @even - true if this this repeater instance has an even index. Note that the array is zero-indexed.
  • @index - Returns the index of this entry within the repeater instance. (Starting from "zero" for the first item)
  • @index_1 - Returns the index of this entry within the repeater instance. (Starting from "one" for the first item)
  1. Complete the TODOs below to create your content layout: 
    1. Write a Handlebars expression to output the "Card Group Header" element.
    2. Write a Handlebars expression to output the "Card Group Introduction" element.
    3. Write a Handlebars expression to output a class "amount-n" where n is the total number of cards to be displayed on one row.
    4. Write a handlebars expression to output the "Card" repeater element.
      Click here to view the solution:

      <section class="card-group-section">
        {{!--1. TODO: Write a Handlebars expression to output the "Card Group Header" element.--}} 
        <h3>{{publish element="Card Group Header" inline-edit="true"}}</h3>
        <div class="card-group-intro">
          {{!--2. TODO: Write a Handlebars expression to output the "Card Group Introduction" element.--}}
          {{{publish element="Card Group Introduction" inline-edit="true"}}}
        </div>
        {{!--3.TODO: Write a Handlebars expression to output a class "amount-n" where n is the total number of cards to be displayed on one row.--}}
        <div class="card-group-content-container {{#each (repeater element="Card")}}{{#if @first}}amount-{{@length}}{{/if}}{{/each}}">
      {{!--4. TODO: Write a Handlebars expression to output the "Card" repeater element.--}}
          {{repeater element="Card" layout="text/card-item"}}
        </div>
      </section>

<section class="card-group-section">
  {{!--1. TODO: Write a Handlebars expression to output the "Card Group Header" element.--}} 
  <h3></h3>
  <div class="card-group-intro">
    {{!--2. TODO: Write a Handlebars expression to output the "Card Group Introduction" element.--}} 
  </div>
  {{!--3.TODO: Write a Handlebars expression to output a class "amount-n" where n is the total number of cards to be displayed on one row.--}}
  <div class="card-group-content-container">
    {{!--4. TODO: Write a Handlebars expression to output the "Card" repeater element.--}}
  </div>
</section>

  1. Click Save changes to save the changes to your content layout.
  2. Enable the Card Section Content Type.
  3. In the Home section, create a Card Section to test the newly created Content Type.

Feedback survey

Congratulations on completing the Advanced Implementer Training module.

Please provide feedback in our on-line survey.