Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

How to show form property Description in meta and on form

Avatar

Level 4

Hi all!

I am using AEM 6.4, but with static templates (so JSP files).

I want to grab the form property "Description" and use for Meta tags for SEO, as well as to show on the form itself. I am trying to put in my template, but cannot seem to get the code right.

The form title is pulled in by the following code:

    <title><%= currentPage.getTitle() == null ? xssAPI.encodeForHTML(currentPage.getName()) : xssAPI.encodeForHTML(currentPage.getTitle()) %></title>

But I cannot get similar code to work for the Description:

   <meta name="description" content="<%= xssAPI.encodeForHTML(currentPage.getDescription()) %>" /> returns null.

Is there an API I have to engage to get the form's description from the properties?

Thanks!

5 Replies

Avatar

Community Advisor

you need to use Properties API.

e.g.

properties.get("jcr:description", "default description");

please check the example here

Fetching Properties From Dialogs | AEM Tips



Arun Patidar

Avatar

Level 4

The page you linked to seems to be for getting information on a component, and not the form itself? Can you clarify?

Avatar

Community Advisor

Yes Christopher, that is to read component properties.

What do you mean by form? Is it page properties?

There are multiple ways to read properties based on where it is stored in CRXDE e.g.

resource.getValueMap().get("description","Default Description")



Arun Patidar

Avatar

Level 4

Hi Arun!

We are building forms using AEM Forms plugin. In the forms, we can set form properties such as title, description, etc. However the only one that seems to be pulled into meta-tags natively is the name and title. When I tried currentPage.getDescription(), I get a null returned. I'm not looking for the component description, but the page description as listed in the form's properties.

prperties.jpg

Avatar

Community Advisor

Hi,
You would be able to get those properties because Page API defines method to get title and tags

com.day.cq.wcm.api.Page

In your case I think

pageProperties.get("jcr:description","default value");

if form save description in jcr:description property



Arun Patidar