Reputation: 827
I am using CQ 5.6.1 and have a requirement wherein we should have the capability to compare page to previous versions. That I believe basically means is we have to induce the versioning capability to components other than the standard out of the box text, the image, the text-image and the title components.
Is that possible ?
Thanks in advance
Upvotes: 0
Views: 629
Reputation: 7080
There is the timewarp feature where you can "scroll" back in time to look at previous versions of the page. You can find this in the sidekick, 4th tab "Versioning" at the bottom. The only downside of this are DAM assets. As they are only referenced by their path only the current version of this asset will be displayed even if you look at an ancient version of the page itself. If the asset was directly uploaded to the page it will be versioned together with the rest of the page.
If you want to approach this programmatically, here a short code snippet I used recently in my current project.
The imports:
import javax.jcr.Session;
import javax.jcr.version.Version;
import javax.jcr.version.VersionHistory;
import javax.jcr.version.VersionIterator;
import javax.jcr.version.VersionManager;
The code:
Session session = currentNode.getSession();
VersionManager vm = session.getWorkspace().getVersionManager();
VersionHistory versionHistory = vm
.getVersionHistory(currentNode.getPath());
VersionIterator vIt = versionHistory.getAllVersions();
while (vIt.hasNext()) {
Version version = vIt.nextVersion();
}
Upvotes: 1