How to write the condition for a text field when a checkbox whose calss name is hero if it's true then for that text field <p> tag will generate otherwise <h1> tag will generate. | Community
Skip to main content
Level 2
June 6, 2024
Solved

How to write the condition for a text field when a checkbox whose calss name is hero if it's true then for that text field <p> tag will generate otherwise <h1> tag will generate.

  • June 6, 2024
  • 1 reply
  • 748 views

below is the p tag for which i need to write condition 
<div class="pad-1-t pad-1-b">
<p style="text-align: left;">${item.offerHeader @ context='html'}</p>
</div>

NOTE- that checkbox is in page properties.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by sravs

Hi @ssin93 , 

 

Use data-sly-element to change the tag according to your condition shown as below.

 

<p style="text-align: left;" data-sly-element=${pageProperties.PROPERTY_NAME? 'p' : 'h1'}>${item.offerHeader @ context='html'}</p>

 

Please refer https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#224-element

 

Hope this helps!!

1 reply

sravs
Community Advisor
sravsCommunity AdvisorAccepted solution
Community Advisor
June 6, 2024

Hi @ssin93 , 

 

Use data-sly-element to change the tag according to your condition shown as below.

 

<p style="text-align: left;" data-sly-element=${pageProperties.PROPERTY_NAME? 'p' : 'h1'}>${item.offerHeader @ context='html'}</p>

 

Please refer https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#224-element

 

Hope this helps!!