Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.
SOLVED

Publish pages when CA uses Editable Template -> Publish Template

Avatar

Level 2

Hello Everyone,

 

I have project requirement which is when content author modifies the editable template structure/content/policies/anything and click publish template(below screenshot).  It should publish automatically all the corresponding pages to publisher and invalidate dispatcher.

 

sreekanthsuggu_0-1700706145212.png

 

 

I want to implement this solution in AEM. How do i implement this one in AEM 6.5 as CS ?

1 Accepted Solution

Avatar

Community Advisor

You need to configured the path in the osgi for which template path your event listener will be called.

 

So you write only one event listener and from osgi config you get the template paths.

https://sling.apache.org/apidocs/sling9/org/apache/sling/api/resource/observation/ResourceChangeList... 

 

example : https://helpx.adobe.com/ca/experience-manager/kb/ReplicationListener.html 

https://github.com/arunpatidar02/aem63app-repo/blob/24aaa3d42fb06f5f43df94a0acefb13bc08807bc/java/Re... 



Arun Patidar
11 Replies

Avatar

Community Advisor

I'm not aware of an AEM ootb feature that provides this feature. If it had been AEM 6.5 I would have suggested using dispatcher flush rules (link below).

However, that feature is not compatible with aem as a cloud service. 

 

One custom approach could be using the AEM replication API within a custom servlet with aem as a cloud service, which of course can be customized to listen for the template publication event and replicate pages that you want using the replication API.

 

https://adobe-consulting-services.github.io/acs-aem-commons/features/dispatcher-flush-rules/index.ht...

 

Replication API example-

https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://experienceleague.adobe.com...

Avatar

Administrator

@sreekanthsuggu  Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni

Avatar

Level 1

Hello @kautuk_sahni ,

 

Thanks for reply. I didn’t find solution anywhere and still looking for solution to implement 

 

Thanks

sree

Avatar

Community Advisor

Hi @sreekanthsuggu 
Why do you need to publish all the pages? Just to invalidate the cache?



Arun Patidar

Avatar

Level 2

Hello @arunpatidar , 

 

Thanks for reply .. 

 

Can you explain what is the event handler/service/etc needs to write when CA clicks on "Publish template" in editable template. 

 

Also i am thinking to use SCD to invalidate the cache. is it ok to use ?

 

Avatar

Community Advisor

Hi @sreekanthsuggu 
You can listen to REPLICATION event and filter based on template path. There is no specific event on publish template



Arun Patidar

Avatar

Level 1

Hello @arunpatidar ,

 

I have to write this utility for many templates in application.

 

How can i write replication event for so many templates ?

 

thanks

Sree

 

 

Avatar

Community Advisor

You need to configured the path in the osgi for which template path your event listener will be called.

 

So you write only one event listener and from osgi config you get the template paths.

https://sling.apache.org/apidocs/sling9/org/apache/sling/api/resource/observation/ResourceChangeList... 

 

example : https://helpx.adobe.com/ca/experience-manager/kb/ReplicationListener.html 

https://github.com/arunpatidar02/aem63app-repo/blob/24aaa3d42fb06f5f43df94a0acefb13bc08807bc/java/Re... 



Arun Patidar

Avatar

Level 2

Hello @arunpatidar , I have created "ResourceChangeListener" and mapped with list of templates(what you recommend) but it's not triggering when CA clicks on publish template in editable templates it works only when template is modified .

 

what to do ?