Expand my Community achievements bar.

SOLVED

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

Avatar

Level 5

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">



Arun Patidar

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