Creating Custom Templates for MultiZone Layouts creating-custom-templates-multizone

This page showcases how you can create a custom template for a multi-zone layout.

Important Considerations considerations

There are two important considerations that you must be aware of before creating a custom template in a multi-zone layout:

  1. Fixed Pixel Size or Percentages:

    Decide whether to use fixed pixel size for different zones for your custom layout or if you want to create a custom layout using percentages.

    note note
    The benefit of using percentage to set zones for your custom layout lets you reuse the template on various screen sizes.
  2. Naming Convention:

    It helps to understand how to create custom multi-zone templates to use in an AEM Screens project. But first, you must understand the verbiage of the templates you want to create.

    table 0-row-2 1-row-2 2-row-2 3-row-2
    Layout Name Description
    Left20-LandscapeHD3Zone A three-zone landscape layout that lets you create three zones:
    * Zone 1 as 20% of the horizontal and vertical screen from the left
    * Zone 2 as 80% of the horizontal screen and 20% of the vertical screen right justified
    * Zone 3 as 100% of the horizontal and 80% of the vertical screen. The aspect ratio is 16:9
    Upper20-PortraitHD2Zone A two-zone portrait template that covers 20% of the screen from the top, with an aspect ratio of 16:9
    Right20-LandscapeSD3Zone A three-zone template that covers 20% of the screen from the right, with an aspect ratio of 4:3
    note important
    The zones defined within the custom layout may not match with the overall aspect ratio of the entire layout. The naming convention followed in this document specifies the aspect ratio of the custom layout as a whole.

Example use case Left20-LandscapeHD3Zone Layout custom-template-one

Follow the section below to create a custom template Left20-LandscapeHD3Zone with the following configuration:

  • Left20 – The top zone on the left covering 20% of horizontal and vertical screen size.
  • Landscape – The screen orientation.
  • HD – The aspect ratio as 16:9.
  • 3Zone – Three zones of the display.

Visual Representation of MultiZone Layout multi-layout-visual-one

The Left20-LandscapeHD3Zone Layout lets you create the following multi-zone layout in your project:


Creating a Left20-LandscapeHD3Zone Layout landscape-layout-one

Follow the steps below to create a Left20-LandscapeHD3Zone Layout for an AEM Screens project.

  1. Create an AEM Screens project titled as customtemplate.


  2. Navigate to CRXDE Lite from your AEM instance > Tools > CRXDE Lite.

  3. Create a folder under apps titled as customtemplate. Similarly, create another folder titled as template under customtemplate, as shown in the figure below.


    note note
    Click Save all from the action bar in CRXDE Lite each time you create, edit, or copy content to any of the nodes. Otherwise, you cannot commit the updates.
  4. Copy the lbar-left template from /libs/screens/core/templates/splitscreenchannel/lbar-left to /apps/customtemplate/template.

  5. Rename the copied lbar-left (/apps/customtemplate/template) to my-custom-layout.

  6. Navigate to /apps/customtemplate/template/my-custom-layout and update the properties jcr:description to Template for Left20-LandscapeHD3Zone and jcr:title to Left20-LandscapeHD3Zone.


  7. Navigate to the offline-config node from /apps/customtemplate/template/my-custom-layout/jcr:content/offline-config and update the jcr:title to Left20-LandscapeHD3Zone.


  8. Navigate to the jcr:content property of my-custom-template from /apps/customtemplate/template/my-custom-layout/jcr:content and update the cq:cssClass property so you can use aem-Layout my-custom-layout.


  9. Referring to step (4) in which you copied the lbar-left template, you can view three responsive grids under my-custom-layout/jcr:content. Add custom css class to each of the responsive grid in the cq:cssClass property, for example, my-custom-layout-top-left for r1c1 node.


    Similarly, add my-custom-layout-top-right for r1c2 and my-custom-layout-bottom for r2c1 node.

    note note
    These custom classes are used in the css to set the width/height for these responsive grids.
    note note
    You can add or remove the responsive grids based on the number of total grids you want. In this example, two grids in the first row, and one grid in the second row are showcased, so there are a total of three responsive grids (r1c1, r1c2, r2c1).
  10. Copy /libs/settings/wcm/designs/screens to /apps/settings/wcm/designs/ and rename the copied design as custom-template-designs.

  11. Navigate to /apps/settings/wcm/designs/custom-template-designs and update the property jcr:title of custom-template-designs to customtemplate-design.

  12. Navigate to /apps/settings/wcm/designs/custom-template-designs and create a file static.css.

  13. Copy the content to static.css file:

    code language-shell
        /*my-custom-layout styles*/ .my-custom-layout--top-left {
        height: 36%;
       float: left !important;
       } .my-custom-layout--top-right {
       height: 36%;
      float: left !important;
      } .my-custom-layout--bottom {
      height: 64%;
    note note
    You can update the percentages to match requirements for your custom template.
  14. Navigate to /apps/<project>/templates/my-custom-layout/jcr:content and update the property cq:designPath to /apps/settings/wcm/designs/customtemplate-designs so you can load the styles configured in static.css.

    note note
    Type all the styles rather than copying or pasting, which can cause white spaces that result in css styling issues.

Viewing the Result viewing-result

Follow the steps below to use the above customized template in your AEM Screens project:

  1. Navigate to your Screens project that you created in step (1) and click the Channels folder.


  2. Click Create from the action bar and click the template Left20-LandscapeHD3Zone from the Create wizard.


  3. After you have created a channel with the customized template, you can add assets to your channel from the editor. The following preview shows the images in a custom template.


Inserting an image as the Background Layer inserting-image

You can insert an image as a background layer to the layout:

You can adjust the CSS rule to use “data-uri” and directly inline the image (Base64 encoded) in the CSS file that you created in (step 13), static.css.

This arrangement is done as follows: { background: url('data:image/…;base64,…') no-repeat center center; }

Or, you can follow the steps below:

  1. Make sure that the image is somehow included in the offline config for the channel.
  2. Use a direct link to the image in the CSS above, instead of the “data-uri” variant.

Updating Background Color updating-color

To change the background color, add the following code to the xml file (step 13), static.css. { background-color: …; }