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

rajashekhar0621

09-02-2018

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?

Accepted Solutions (1)

Accepted Solutions (1)

Ravi_Pampana

MVP

09-02-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.