Content Fragments in Depth. CF Deactivation. Part 3.5
Table of contents
Having looked at replication, we’ll now explore content fragment deactivation. If we go to the first article in this series, we’ll see there are 2 types of pages: Webinar and Event Page. An author starts by creating an Event Content Fragment, then it’s picked up by the process and no more manual involvement is needed. Once the Event has taken place and the webinar video has been uploaded, there’s no need for this in this Event Page as it points at an expired event. So, as not to unpublish it manually, we set up a mechanism to automate this process.
Content Fragment Setup
First of all, we decided to let an author decide whether a Content Fragment should be deactivated automatically by adding a new property into the Event CF Model
Deactivation Job
A new job is introduced to handle this process. com.wcm.site.jobs.deactivation.impl.EventCFDeactivationScheduler:
And a json config for it:
And the consumer itself. com.wcm.site.jobs.deactivation.impl.EventCFDeactivationJobConsumer:
And its config:
And a simple method to query expired CFs. com.wcm.site.services.indexgrid.service.impl.IndexSearchService:
As we’re searching for the following properties “cq:lastReplicationAction”
, “deactivateOnExpire”
, “endDate”
– make sure to add them to the corresponding indexes.
That’s pretty much it. This is just a CF real usage example. You don’t have to, and wouldn’t need to, copy it completely. But we hope that this series of articles will add some ideas on how to incorporate CFs into a project and automate a lot of manual processes. Need a hand with coding? Look no further! We’re AEM developers who know this CMS inside out. We’re here to help!
Author: Iryna Ason
Was this article useful for you?
Get in the know with our publications, including the latest expert blogs
End-to-End Digital Transformation
Reach out to our experts to discuss how we can elevate your business