Tech Tips

AEM Content Fragments in Depth: Introduction. Part 1

In the previous set of articles about AEM Content Fragments, we explained some basic concepts and very simple usage examples. But there’s still more to talk about, especially when it comes to the power that AEM content fragments have to generate data. As a team who offers AEM consulting services, we can walk you through workarounds related to content fragments.

AEM Content Fragments: How It All Started

After AEM content fragments’ introduction to our site, we rethought our whole approach to data management. Before, Page or Experience Fragments were our primary units of data. Both Pages and Experience Fragments come with styles, so while they could be reused without changing styles, they couldn’t be replicated as “pure,” style-free data.

Content Fragments, like any Asset, aren’t styled and serve as a deeper level of data abstraction. They are easier to create and manage, and then, since you have the raw data, you can reuse one AEM content fragment in different components. One single AEM content fragment can stand for the component on the page, a card to click, or even the whole page. But that’s not all! AEM content fragments can be created manually, or, when connected to any internal or external data source, automatically.

With all that in mind, a tempting idea appeared to us: what if we automated AEM content fragment creation, the relationship between content fragments and pages or components using specific rules, and eventually content fragment destruction when it expires?

A Use Case

We’ll use the example of two basic pages: “Event” and “On Demand Webinar.” The Event page serves as an alert or notification for a future webinar, as well as a place for registration. On-Demand webinar pages store past webinar recordings and have an external video source. Each page has its own template.

While Event data is created manually (at least some parts of it: a real person decides when the webinar should start, its topic, etc ), the On-Demand Webinar page creation can be fully automated.

This means we can minimize the author’s involvement, and thereby reduce potential content errors. So all we need to do is create an Event AEM content fragment (manually) and set up video data sync-up. And then the magic starts!

Data Models

As the real data models are complicated and probably not relevant to this article, let’s simplify the AEM content fragment models.

Video Model

  • Title
  • External System ID
  • Duration
  • Created At Date
  • Poster Link
  • Tags (by default “video” tag will be set to determine the content type)

Event or On Demand Video Model

  • Name
  • Start Date
  • End Date
  • Form ID (Optional, the ID of the registration form for the upcoming event)
  • Webinar Video Reference (Optional, a reference to the video record for On-Demand videos)

The other auxiliary fields will be introduced as they appear.

AEM Content Fragments: Make It Work

It all starts with the Event content fragment creation. At this point, the author will decide to create a page or Experience Fragment and relate the newly created AEM content fragments to it, roll this page out to the needed locales, and publish them instantly (or send to translation and then publish).

As the event takes place and the recording is being uploaded, the sync-up process starts. It will pull video metadata and create a Video content fragment. As soon as the author has the Webinar Reference set to Event – the Upcoming event turns into an On-Demand video page. We’ll need to recreate (and again, rollout, translate, and publish) a corresponding video page and unpublish the existing Upcoming Event page.

If this sounds a bit too complex, don’t worry! It all comes together – we promise. Stay tuned for more articles, where we’ll describe this process step by step!

Author: Iryna Ason