January 1, 2021
Estimated Post Reading Time ~

Content Fragments in AEM - High level pointers

Content Fragments(CF), an implementation for re-using content across multiple locations/channels, a means for headless-CMS.
jcr:primaryTypeContent Fragments(CF) is of asset type - dam:Asset to hold mixed-media content - Text and Assets.
Types
  • Simple Fragment, Created out of Fragment Template named "Simple Template" OOB
  • Structured Fragment, Created out of Content Fragment Model(CFM)
Note:  Per 6.5 Adobe docs, it is recommended to create CF using CFM.
Simple TemplateDefines a single "Multiline text" element.
Content Fragment Model(CFM)Offers different data types to define the type of content. (Single line, Multiline text, Date field, Numberfield, dropdown, and so on OOB and an option to render each of this in the multifield format as well. )
ElementsEach of these data types that we define as part of CFM is referred to as Elements in CF
Multiline Text element
  • It is available in 3 types/formats
    • Rich Text, text/html
    • Plain Text, text/plain
    • Markdown, text/x-markdown
  • It has options to switch between above said types, Text Statistics(data about the content like No. of words, characters, sentences), Import Content(Option to locate plain ".txt" file to include content), Sync with Master(Copy changes from Master to Variation and not vice-versa)
Note:  Assets cannot be included in Plain text mode. Markdown can have reference to Assets per its syntax. 
VariationsWe can create as many Variations out of Master which in turn has options to "Rename, Delete, Sync with Master".
Note: Sync with Master is enabled only for Multiline Text element/data type.
Associated ContentAn option in CF lets us add related Collections to the fragment which will help list related assets when including CF in site pages.
Note: We can add CF itself to be part of the same collection for easy tracking. 
Inclusion in site pagesCreated CF can then be added to pages via Content Fragment and Content Fragment List component from General group or creating proxy out of core components.
In-between contentWhen included on the page, we will have the means to add "in-between" content which can be
  • Component
  • Asset
  • Associated content.
Note: These are part of the page content and not the fragment content. (as it is authored at page level after locating content fragment)
API/Access programmaticallyBelow mentioned interfaces are available for accessing content fragments/templates/elements/variations and its related from com.adobe.cq.dam.cfm.*
Pre-requisites(before creating CFM/CF)CFM is part of the configuration and hence the same needs to be enabled in /conf via Configuration Browser. (General -> Configuration Browser)
  • Eg. Sample CFM for project named "learnings" - /conf/learnings/settings/dam/cfm/models/events
  • In this case, CFM should be allowed at the learnings folder level (Folder properties)
As CF is an asset and is to be created using CFM (which acts as a template for creating CF), the same needs to be allowed at the desired DAM folder level.
  • Eg. If CF is to be created for project "learnings" then at /content/dam/learnings -> Properties -> Cloud services -> Cloud Configuration field -> Locate respective "/conf" path (/conf/learnings)
Use cases:
  • Content related to events, news articles, press releases, product details can be part of CF where we can define structured content via CFM.
  • Single multiline content scenarios like privacy, terms, and conditions can be part of CF, defined at the project level can be used across locales. (by leveraging translation)
Related screenshots for reference:



By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.