[opencms-dev] Determine the project a change was made in

Kai Widmann kai.widmann at ews-schoenau.de
Fri Feb 14 16:52:31 CET 2025


Hey there,

I have a custom caching mechanism that stores some stuff in a project specific way (Offline / Online). Now I’d like to flush the cache in two distinct situations:

  *   Once a container page is edited (and saved) by an editor in the Offline project, I’d like to flush the Offline cache
  *   Once a container page is published from the Offline to the Online project, I’d like to flush the Online cache

The second thing is not a problem, I can use a module action and react to the publishProject event.
For the first thing I guess I’d have to use I_ModuleActionHandler’s cmsEvent method to react to EVENT_RESOURCE_MODIFIED and/or some other resource events.
But these are fired after an editor changed the resource AND after publishing, so more often than I’d like. Is there any way to figure out, if a resource was changed in the Offline project or published to the Online project in I_ModuleActionHandler’s cmsEvent method? I used resource.getProjectLastModified() and used this to determine the Project, but this always is Offline. So it doesn’t help. What I would need is something like “resource.getCurrentProject” or event.getCurrentProject, but both do not exist. Also the eventData (event.getData()) doesn’t contain any project specific information.

Any ideas would be appreciated!

Mit freundlichen Grüßen

Kai Widmann
Webentwickler Backend

EWS Elektrizitätswerke Schönau eG
Lehrter Straße 57 Haus 1 | 10557 Berlin
Hauptsitz: Friedrichstraße 53/55 | 79677 Schönau

www.ews-schoenau.de<https://www.ews-schoenau.de/>

Vorstände
Anja Burde,
Armin Komenda,
Alexander Sladek,
Sebastian Sladek

Aufsichtsratsvorsitzender
Thomas Jorberg

Genossenschaftsregister
GnR 700017 beim AG
Freiburg im Breisgau

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20250214/90b8088f/attachment.htm>


More information about the opencms-dev mailing list