Show Menu
TOPICS×

Experience Fragments

The Basics

An Experience Fragment is a group of one or more components including content and layout that can be referenced within pages.
An Experience Fragment Master and/or Variant uses:
  • sling:resourceType : /libs/cq/experience-fragments/components/xfpage
As there is no /libs/cq/experience-fragments/components/xfpage/xfpage.html it reverts to
  • sling:resourceSuperType : wcm/foundation/components/page

The Plain HTML Rendition

Using the .plain. selector in the URL, you can access the plain HTML rendition.
This is available from the browser, but its primary purpose is to allow other applications (for example, third party web apps, custom mobile implementations) to access the content of the Experience Fragment directly, using only the URL.
The plain HTML rendition adds the protocol, host and context path to paths that are:
  • of the type: src , href , or action
  • or end with: -src , or -href
For example:
.../brooklyn-coat/master.plain.html
Links always reference the publish instance. They are intended to be consumed by third parties, so the link will always be called from the publish instance, not the author.
The plain rendition selector uses a transformer as opposed to additional scripts; the Sling Rewriter is used as the transformer. This is configured at
  • /libs/experience-fragments/config/rewriter/experiencefragments

Social Variations

Social variants can be posted on social media (text and image). In AEM these social variants can contain components; for example, text components, image components.
The image and text for the social post can be taken from any image resource type or text resource type at any level of depth (in either the building block or layout container).
Social variations also allow building blocks and take them into consideration when making social actions (on the publish environment).
To post the correct text and image to the social media network, some conventions need to be respected if you are developing your own customized components.
For this, the following properties must be used:
  • For extracting the image
    • fileReference
    • fileName
  • For extracting the text
    • text
Components that do not use this convention, will not be taken into consideration.

Templates for Experience Fragments

Only editable templates are supported for Experience Fragments.
When developing a new template for Experience Fragments you can follow follow the standard practices for an editable template .
To create an experience fragment template that is detected by the Create Experience Fragment wizard, you must follow one of these rule sets:
  1. Both:
    1. The resource type of the template (the initial node) must inherit from: cq/experience-fragments/components/xfpage
    2. And the name of the template must begin with: experience-fragments This allows users to create experience fragments in /content/experience-fragments as the cq:allowedTemplates property of this folder includes all the templates that have names beginning with experience-fragment . Customers can update this property to include their own naming scheme or template locations.
  2. Allowed templates can be configured in the Experience Fragments console.

Components for Experience Fragments

Developing components for use with/in Experience Fragments follow standard practices.
The only additional configuration is to ensure that the components are allowed on the template, this is achieved with the Content Policy .