Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

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

rajashekhar0621
Level 2
Level 2

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?

1 Accepted Solution
Ravi_Pampana
Correct answer by
Community Advisor
Community Advisor

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.

View solution in original post

2 Replies
Ravi_Pampana
Correct answer by
Community Advisor
Community Advisor

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.

View solution in original post