I need to display labels "New" and "Updated" besides the links displayed on a page on my website.
For this I applied a logic of checking number of versions. If number of versions are more than 2 I displayed "updated" else i displayed "New". I am able to achieve it in the Author environment.
But in Publish environment, Number of versions created for a page, even though the page is modified and republished, are one only. So how can i identify that whether the page is published first time or it has been published multiple times.
Solved! Go to Solution.
Views
Replies
Total Likes
One suggestion to this is to implement you own servlet/listener that listens to the replication events. Look at the EventHandler and JobProcessor interfaces. This servlet could then for example set a property value on the component instance so that the component could be displayed different the first time. It could just be a small counter variable that keeps track of how many times the actualy thing has been published or some more fancy logic there :)
//imports @Service... @Component... @Property(name = "event.topics", value = ReplicationAction.EVENT_TOPIC) public class MyCustomEventHandler implements EventHandler, JobProcessor { private static final Logger LOGGER = LoggerFactory.getLogger(MyCustomEventHandler.class); @Override public void handleEvent(Event event) { LOGGER.info("Handling an event of some kind !!"); process (event); } @Override public boolean process(Event event) { LOGGER.info("Processing an event !!"); ReplicationAction action = ReplicationAction.fromEvent(event); if (action.getType().equals(ReplicationActionType.ACTIVATE)) { LOGGER.info("Processing an activation job, this is just what we are looking for !!!!!"); //Logic for fetching/setting the properties you want from the component you want //goes here. Here you can make use of the action.getPath(); to get hold of the containing page //and then later on any specific components... } return true; } }
Views
Replies
Total Likes
Is the component that implements the version-checking logic deployed to the publish instance?
scott
Views
Replies
Total Likes
One suggestion to this is to implement you own servlet/listener that listens to the replication events. Look at the EventHandler and JobProcessor interfaces. This servlet could then for example set a property value on the component instance so that the component could be displayed different the first time. It could just be a small counter variable that keeps track of how many times the actualy thing has been published or some more fancy logic there :)
//imports @Service... @Component... @Property(name = "event.topics", value = ReplicationAction.EVENT_TOPIC) public class MyCustomEventHandler implements EventHandler, JobProcessor { private static final Logger LOGGER = LoggerFactory.getLogger(MyCustomEventHandler.class); @Override public void handleEvent(Event event) { LOGGER.info("Handling an event of some kind !!"); process (event); } @Override public boolean process(Event event) { LOGGER.info("Processing an event !!"); ReplicationAction action = ReplicationAction.fromEvent(event); if (action.getType().equals(ReplicationActionType.ACTIVATE)) { LOGGER.info("Processing an activation job, this is just what we are looking for !!!!!"); //Logic for fetching/setting the properties you want from the component you want //goes here. Here you can make use of the action.getPath(); to get hold of the containing page //and then later on any specific components... } return true; } }
Views
Replies
Total Likes