SiteVision Onlinehelp
Search

Script to extract first archive

Question: How do I retrieve a jcr node corresponding to the first archive directly underneath a specific page?

Answer: The following script demonstrates the solution

var utils = request.getAttribute("sitevision.utils");

// Get the page Node (in this case current page are used)
var currentPage = utils.getPortletContextUtil().getCurrentPage();
var archive = null;

for (i = currentPage.getNodes(); i.hasNext();)
{
   var potential = i.next();
   if (potential.isNodeType("sv:archive"))
   {
      archive = potential;
      break;
    }
}
if (archive == null)
   out.println("No archive found");
else
    out.println("Found archive: "
                    + archive.getProperty("displayName").getString());

Last updated:

se-sto-pio-sv5-2
216.73.217.134