BG_ADV_CCT_003_Using repeaters to duplicate content blocks in custom Content Templates

In this tutorial, we will learn how to use the Repeater field type within our custom Content Templates.

The Repeater field type allows us to create easily duplicated code and input fields within the same Content Template.

For example, if we require several text and image combinations (in the same format, but with different content) then we could easily accomplish this using a repeater.

In this example, we will add a Repeater to our custom Content Template to allow the input of additional text and image data.

Infigosoftware

  1. 1. Boilerplate code

    To begin, a new section of boilerplate code has been added to our HTML markup.

    This is not a necessity, but will create a completely new section on our page, allowing us to keep this section of the tutorial isolated.

    The additional code section added consists of the following:

    <section class="section is-medium has-background-default has-text-default additional-section"> <div class="container content is-flex"> <h2 class="title"> Additional information is shown below </h2> <div class="box is-light additional-container"> Additional information goes here </div> </div> </section>

    Boilerplate code
  2. 2. Click on Add new field

    We will create a new field, in the same area we previously created the Page Title and Description fields.

    Click on Add new field
  3. 3. Type a field name

    Type a field name
  4. 4. Select Repeater from the field type

    Select Repeater from the field type
  5. 5. Click on Create

    Click on Create
  6. 6. Input the newly generated Placeholder for the repeater in to the HTML markup code

    Input the newly generated Placeholder for the repeater in to the HTML markup code
  7. 7. Click on Save and Continue Edit

    Click on Save and Continue Edit
  8. 8. Next, we will begin to populate the Repeater itself

    The process is virtually identical to the creation of HTML markup and fields done in this and previous tutorials.

    The primary difference is that this section is isolated, meaning we can easily duplicate its content within this Content Template.

  9. 9. Click on button

    Click on button
  10. 10. HTML editor

    The Repeater contains another HTML editor. The contents of this editor will be placed where the Repeater field placeholder is located in the main HTML markup code.

    HTML editor
  11. 11. Click on Add new field

    Fields can be created within the Repeater itself, for use in the Repeater HTML editor

    Click on Add new field
  12. 12. Create new fields

    In this example, we will create a new TextArea (for paragraph text) and image fields.

    Create new fields
  13. 13. Input code into the Repeater HTML editor

    Code can be placed in this editor as with the primary HTML Markup editor.

    In our example, we will utilise some boilerplate code providing text and an image

    <div class="block"> </div> <div class="block has-text-inherit"> <div class="is-inline-block "> <div class="ict-image image is-as-image "> <img src="" alt="" class=""> </div> </div> </div> <hr />

    Input code into the Repeater HTML editor
  14. 14. Input the Repeater field placeholders into the Repeater HTML editor

    Input the Repeater field placeholders into the Repeater HTML editor
  15. 15. Click on Save and Continue Edit

    Click on Save and Continue Edit
  16. 16. Launch the Content Page and select the custom Content Template

    Our Additional Information section is now available at the bottom of the custom Content Template, along with an "Add New" button.

    By default, Repeater content is excluded until specifically added. Each click of "Add New" will add a new instance of our Repeater HTML code and fields, allowing different data to be placed in each.

    Launch the Content Page and select the custom Content Template
  17. 17. Click on Add new (x2)

    Click on Add new (x2)
  18. 18. Two instances of our Repeater code have now been added and are ready to populate

    Two instances of our Repeater code have now been added and are ready to populate
  19. 19. Populate the field contents

    Populate the field contents
  20. 20. Click on Save and Continue Edit

    Click on Save and Continue Edit
  21. 21. Launch the Content Page to see the populated data

    Launch the Content Page to see the populated data