Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

How do I Access Template properties in a new Servlet

Avatar

Former Community Member

All my templates have a couple properties that are not getting imported into pages.  These properties need to be read to populate the SiteMap, they are Priority and Update Frequency.

The current com.adobe.acs.commons.wcm.impl.SiteMapServlet.java is looking for those properties in the page, not the template, and since they're not there, doesn't report them.  So I have 2 problems:

1)  In the CreatePage, I need to copy the values from the template into the page.  Reasonably straightforward, though I can't seem to hide the values from the user.  Currently, there is no requirement to allow anyone to change the values at the page level.

2)  For the pages generated prior to the 1) fix (call those legacy pages), I need to access the template properties.  I created a new SiteMapServlet called SiteMapServletMine which is a copy of SiteMapServlet (since it is final, I can't extend it).  I can access the Template from the Page, but cannot see how to access the properties in that template.

Note that a better* solution may be to write script to populate all the legacy pages from their templates, but that still begs the question, how do I access the properties?

* Better because then future changes to the template will not affect legacy pages.

I am using AEM 6.2

4 Replies

Avatar

Level 10

Can you give examples of what template props you need in a page that are not there. THis will help.

Avatar

Former Community Member

The template props are there, "sitemapPriority" (0.5) and "sitemapUpdateFrequency" (Weekly).  The SiteMapServlet looks for "changefreq" and "priority" in the page properties. The page properties (based on the RUNMODE) for "priority.properties" and "changefreq.properties" are empty, not 0.5 and Weekly.  Note that I also need to do a translation of the video URL for the SiteMap.  Is this what you are looking for?

Avatar

Level 10

These are not typical template props that are set when creating a static template.

Templates - docs.adobe.com

Anyhow - if you need the values of these properties which are set a template node - you can use JCR API to retrieve the node and read the property values. I cannot think of another way other than querying these prop values.

Avatar

Former Community Member

Sure, these are added when creating our own templates.  I am customizing the page creation process to copy those values into the appropriate page properties so the SiteMapServlet will use them.  I guess need to learn more about the JCR API in order to access them.  Since I need to customize the SiteMapServlet, how do I ensure that AEM uses my version?