Posts tagged "Wiki"

Recent Wiki Activity

This post is in continuation of the previous one where we added a component to display the upcoming events of a calendar.

Here we would create a similar component and try to display the status of the recent wiki activity.


As usual go ahead and create a new component using the component wizard in the CRXDE.


Once done open up the JSP page and add following piece of code to retrieve the nodes.

String queryStatment = "select * from wiki:Topic where jcr:path like '"+currentPage.getPath()+"/wiki/%'order by wiki:lastModified desc";
Query q = currentNode.getSession().getWorkspace().getQueryManager().createQuery(queryStatment,Query.SQL);
NodeIterator nodeIter = q.execute().getNodes();

Iterate through the node entries and retrieve the version history like

VersionHistory vh = node.getVersionHistory();
long size = vh.getAllVersions().getSize();

For newly added wiki entries the version size would be 1 and for all other updated entries it will be greater than 1.


After adding valid wiki entries and adding the component to the page it should resemble like given below.




Share on Facebook