manipulate node content when publishing in aemaacs | Community
Skip to main content
September 19, 2024
Solved

manipulate node content when publishing in aemaacs

  • September 19, 2024
  • 4 replies
  • 1675 views

i need to manipulate node content programatically after author click quick publish button and send changed content to replication agent for activation. 

that is i need to filter put some paths from the published content and  send filtered content to replication agent for pubishing.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by joerghoh

I don't think that the replication API allows you to modify content (that means: changing the values of properties and/or add/remove nodes) which is then sent only to the publish, but which is not persistet on the authoring instance.

4 replies

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
September 19, 2024

Hi,

 

I recommend that you go through this article, which explains replication quite well: Replication Under the Hood. Beyond that, I think you should look into the Preprocessor interface. Here are some examples:

 

Hope this helps!

Esteban Bustamante
AliSyed1Author
September 19, 2024

I have read it but I want it to work on quick publish button only and not for manage publication.

pulkitvashisth
Community Advisor
Community Advisor
September 19, 2024

Hi @alisyed1 


What you can do for this is create a Sling Event Handler and bind it to replication event on publish.


This will get called every time a page is replicated to the publisher.
Here you can write the logic to modify the page replicated as you please:

Here is sample code of how you can register such a Handler on AEM Publish instance.

 

 

@Component(service = EventHandler.class, immediate = true, property = { Constants.SERVICE_DESCRIPTION + "=Listener on page replication", EventConstants.EVENT_TOPIC + "=" + ReplicationEvent.EVENT_TOPIC }) public class OnPublishReplicationEventHandler implements EventHandler { @Override public void handleEvent(final Event event) { //write your logic here } }

 

 

 

AliSyed1Author
September 20, 2024

is n't it triggers when page is published?i want to change content when publish is clicked.

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
September 21, 2024

I don't think that the replication API allows you to modify content (that means: changing the values of properties and/or add/remove nodes) which is then sent only to the publish, but which is not persistet on the authoring instance.

AliSyed1Author
September 27, 2024

yes but we can prevent some nodes or properties from activating using replication content filter.

kautuk_sahni
Community Manager
Community Manager
September 25, 2024

@alisyed1 Did you find the suggestions helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!

Kautuk Sahni