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.
SOLVED

How to check multiple If conditions in sighlty

Avatar

Level 5

Hi Team, 

I'm trying multiple if conditions for my code. as far as i know the below conditional check 

 

value ="${properties.val1 ? properties.val1 : inheritedPageProperties.val1}">

for this i need to add another default value , like if the value is present in component dialogue it should take from component else it should take from rootpage properties. If the value is not preset in both component and rootpage then I need to give my own default value?("some text").

 

how can I do this ?

1 Accepted Solution

Avatar

Correct answer by
Level 3

@Tessa_learner1 You can wrap your ternary expression in parenthesis and use an OR (||) condition to achieve this.

${(properties.val1 ? properties.val1 : inheritedPageProperties.val1) || 'Default'}

 

View solution in original post

3 Replies

Avatar

Community Advisor
<sly data-sly-set.value="${properties.val1 ? properties.val1 : inheritedPageProperties.val1 || 'default value'}"></sly>

you can try this way.. In this ternary condition if ${propertise.val1} is not present then it will check ${inheritedPageProperties.val1} and if ${inheritedPageProperties.val1} this value is also not present then it will take the default value provided by OR(||) condition

Avatar

Correct answer by
Level 3

@Tessa_learner1 You can wrap your ternary expression in parenthesis and use an OR (||) condition to achieve this.

${(properties.val1 ? properties.val1 : inheritedPageProperties.val1) || 'Default'}

 

Avatar

Level 5

Hi @cshawaus , 

Thank you so much for the response. I tried this, it's working.