How can I test whether both the field are not empty in dialog in sightly | Community
Skip to main content
Employee
Jul 20, 2021 6:00 PM UTC
Solved

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

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
BimmiSoAccepted solution
Employee
Jul 21, 2021 6:13 AM UTC

Hi @keerthana_h_n ,

 

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

 

4 replies

VeenaVikraman
New Participant
Jul 21, 2021 9:47 AM UTC

@keerthana_h_n 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

Translate
BimmiSoAccepted solution
Employee
Jul 21, 2021 6:13 AM UTC

Hi @keerthana_h_n ,

 

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

 

Translate
arunpatidar
New Participant
Jul 20, 2021 8:49 PM UTC

Hi try

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

Translate
Arun Patidar
Shubham_borole
New Participant
Jul 20, 2021 6:55 PM UTC

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

Translate