Expand my Community achievements bar.

SOLVED

Email Notification on Page Activation

Avatar

Level 3

I want to send an email notification wen a page is activated, but there are also modifications since the last activation.

For now, we have implemented an event handler that detects the ACTIVATE events.

Is there a way to check if the page has also been modified since the last activation?

 

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

You can keep a custom property to track activation date, now when ever you are activating a page,  compare last modified property and custom property ( last activation date). If last modified is greater than last activate date, it means page has been modified and then update this property with new activation date.

View solution in original post

5 Replies

Avatar

Level 10

You can read the cq:lastmodifieddate date property of that page stored in jcr:content

Avatar

Level 3

How will that help me? if I activate the same page twice, the last modification date stays the same, while the activation date changes, so my event handler is triggered. How do i know that the modified date changed between two activations?

Avatar

Level 10

Use getPath() to check which property gets changes and add PROPERTY_CHANGED  changed event on the node path

if cq:lastmodified  changes, getPath() will return something similar to  path will be [node path]/cq:lastmodified

http://www.day.com/specs/jsr170/javadocs/jcr-1.0/javax/jcr/observation/Event.html#getPath()

Avatar

Level 3

But the event i'm listening to is the activate event, not the PROPERTY_CHANGED event. I need to detect the activation events in order to trigger notification emails.

Avatar

Correct answer by
Level 10

You can keep a custom property to track activation date, now when ever you are activating a page,  compare last modified property and custom property ( last activation date). If last modified is greater than last activate date, it means page has been modified and then update this property with new activation date.