It is not recommended to extend or change the actual components as they are still subject to change.
Adobe Experience Manager (AEM) content fragments are created and managed as page-independent assets. They allow you to create channel-neutral content, together with (possibly channel-specific) variations. You can then use these fragments, and their variations, when authoring your content pages; you can also use an existing content fragment asset by dragging it from the asset browser to the page (as for other asset based components, such as the foundation component Image). The out-of-the-box content fragment component displays only one element of the referenced content fragment. Using the component dialog you can define the element, variation and range of fragment paragraphs that you want to display on the page.
The Content Fragment component has been introduced in AEM 6.2 as an enhanced version of the Article component (of Geometrixx Media) that has been deprecated.
The Content Fragment component is used to hold a reference to a content fragment asset (effectively enhanced text assets). The resource type for the content fragment is:
Only the touch-optimized editor fully supports content fragment components. The touch-optimized editor includes the client library:
This library adds features, specific to content fragments, to the editor; for example, support for the ability to add and configure content fragments on the page, to search for content fragment assets in the asset browser and for associated content in the side panel.
The Content Fragment component allows you to drop additional components in-between the different paragraphs of the displayed element. Basically, the element displayed is composed of different paragraphs (each paragraph is marked by a carriage return); between each of those paragraphs, you can insert content using other components.
From a technical viewpoint, each paragraph of the displayed element lives in its own parsys, and each component that you add in-between the paragraphs will be (under the hood) inserted into the parsys.
In other words, if the instance of the content fragment component is composed of three paragraphs, then the component will have three different parsys in the repository. All of the in-between content that is added to the content fragment will actually be located inside these parsys.
In the repository the in-between content is stored relative to its position inside the overall paragraph structure; i.e. it is not attached to the actual paragraph content.
To illustrate this, let us consider that we have:
- an instance of a content fragment composed of three paragraphs
- and that some content has already been inserted after the second paragraph
- This means that the content will be stored in the second parsys.
Basically, if the paragraph structure of this instance changes (by changing the variation, element, or range of paragraphs displayed), it could affect the in-between content displayed when the content fragment content:
- is edited and another paragraph is added before the second paragraph:
- The in-between content will be displayed after the newly created paragraph (the second parsys now holds the newly created paragraph).
- is edited and the second paragraph is removed:
- The in-between content will be displayed after the paragraph that was previously the third (the second parsys now holds the previous third paragraph).
- is configured so that only the first paragraph is shown:
- The in-between content will not be displayed (the second parsys is not rendered anymore due to the new configuration).
To use the out-of-the-box content fragment component as a blueprint for extension you should respect the following contract:
- Reuse the HTL rendering script and its associated POJO to see how the in-between content feature is implemented.
- Reuse the content fragment node: cq:editConfig
- The afterinsert/afteredit/afterdelete listeners are used to trigger JS events. These events will be handled in the cq.authoring.editor.plugin.cfm client library to display the associated content in the side panel.
- The cq:dropTargets are configured to support dragging content fragment assets.
- cq:inplaceEditing is configured to support authoring of a content fragment in the page editor. The fragment in-place editor is defined in the cq.authoring.editor.plugin.cfm client library and allows a quick link to open the current element/variation in the fragment editor.