Is it possible to compare a page property with a component property within a component? | Community
Skip to main content
Level 2
February 9, 2018
Solved

Is it possible to compare a page property with a component property within a component?

  • February 9, 2018
  • 2 replies
  • 1904 views

I have a page whose title is being set to, let's say, "foo".

I have a component contained within that page (across all the 3 pages referenced, really) who contains 3 links. I'm attempting to compare the _page-leve_ property title with the _component-level_ property linkXtext:

<a href="mypage1.html" class="tab ${properties.jcr:title==properties.link1text ? "active" : ""}">{properties.link1text}</a>

<a href="mypage2.html" class="tab ${properties.jcr:title==properties.link2text ? "active" : ""}">{properties.link2text}</a>

<a href="mypage3.html" class="tab ${properties.jcr:title==properties.link3text ? "active" : ""}">{properties.link3text}</a>

The respective values of said linktexts being

1 = sna

2 = foo

3 = bar

The underlying theory here being that, should the two strings match, the classNam active will be appended, otherwise, omitted.

I can read the linkXtext no problem, but the page title seems to elude me. Thoughts?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Ravi_Pampana

Hi,

${properties.key} will return the value if variable is present in the component, I think you are trying to read page level property inside a component. In that case you can use

${pageProperties['jcr:title']}

When reading value having : the above format works.

Hope this helps.

2 replies

Ravi_Pampana
Community Advisor
Ravi_PampanaCommunity AdvisorAccepted solution
Community Advisor
February 9, 2018

Hi,

${properties.key} will return the value if variable is present in the component, I think you are trying to read page level property inside a component. In that case you can use

${pageProperties['jcr:title']}

When reading value having : the above format works.

Hope this helps.

Level 2
February 9, 2018

Thank you so much for the help.