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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

[AEM Gems Webinar] Accelerating Experience Manager as a Cloud Service development with Rapid Development Environments
Adobe Summit 2023 | Complete list of AEM Sessions & Labs
SOLVED

How can I test whether both the field are not empty in dialog in sightly

Avatar

Level 4

Hi all,

 

I'm trying check whether both the fields are present in the dialog using or condition. It is failing how can I use 'or' condition in data-sly-test for fields renditions in single div.

 

<div data-sly-test="${contentFragmentMap.elementsMap.twitterLinkGeneral}" || data-sly-test="${contentFragmentMap.elementsMap.linkedinLinkGeneral}" class="cmp-auth-profile__social-buttons">

 

I tried above statement but its failing. Can anyone help me with this?

 

Thank you

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi @keerthana_hn ,

 

The syntax is incorrect as if you need to add OR condition sly-test you can write as below.

<div data-sly-test="${condition 1 || condition 2}">

 

Please try as below:

 

<div data-sly-test="${contentFragmentMap.elementsMap.twitterLinkGeneral || contentFragmentMap.elementsMap.linkedinLinkGeneral}" class="cmp-auth-profile__social-buttons">

 

Hope this helps!!

 

Thanks

 

View solution in original post

4 Replies

Avatar

Community Advisor

Hi,

Please try 

 

<p data-sly-test="${properties.jcr:title || properties.myTitle}">My Text</p>

 

or

 

<div data-sly-test="${contentFragmentMap.elementsMap.twitterLinkGeneral || contentFragmentMap.elementsMap.linkedinLinkGeneral}" class="cmp-auth-profile__social-buttons">

 However this or condition can be checked in model and passed as a boolean to be checked in the html

Avatar

Community Advisor

Hi try

<div data-sly-test="${contentFragmentMap.elementsMap.twitterLinkGeneral || contentFragmentMap.elementsMap.linkedinLinkGeneral}" class="cmp-auth-profile__social-buttons">

Avatar

Correct answer by
Employee Advisor

Hi @keerthana_hn ,

 

The syntax is incorrect as if you need to add OR condition sly-test you can write as below.

<div data-sly-test="${condition 1 || condition 2}">

 

Please try as below:

 

<div data-sly-test="${contentFragmentMap.elementsMap.twitterLinkGeneral || contentFragmentMap.elementsMap.linkedinLinkGeneral}" class="cmp-auth-profile__social-buttons">

 

Hope this helps!!

 

Thanks

 

Avatar

Community Advisor

@keerthana_hn In your query ( i copied it below) you need to remove the characters marked in bold letters 

 

<div data-sly-test="${contentFragmentMap.elementsMap.twitterLinkGeneral}" || data-sly-test="${contentFragmentMap.elementsMap.linkedinLinkGeneral}" class="cmp-auth-profile__social-buttons">

 

AS others mentioned it should be

 

<div data-sly-test="${contentFragmentMap.elementsMap.twitterLinkGeneral || contentFragmentMap.elementsMap.linkedinLinkGeneral}" class="cmp-auth-profile__social-buttons">

 

Thanks

Veena