Monday 19 April 2021

Sightly Tips and Tricks

1) How to pass some value to helper

<sly data-sly-use.linkHelper="${'com.abc.components.LinkHelper' @ linkPathValue = pagePath }" />

And in helper read the value like shown below [helper is inhereted from WCMPojo]

String linkPath = get("linkPathValue", String.class);


2) How to iterate child nodes from Sightly

<sly data-sly-test="${resource.hasChildren}" data-sly-list="${resource.listChildren}">

${item.name}

 </sly>


3) Allow only one component in layoutcontainer [responsive grid] [Validation]

In responsive grid node like

/conf/abc/settings/wcm/policies/wcm/foundation/components/responsivegrid/policy_2869956

Add below property

acsComponentsLimit [Long] 1


4) How to make it18n value dynamic

Example: for us value should be "10 minutes"

                for uk value should be "minutes 10"

Where this number [minutes] should be some dynamic value and minute_read should e translated key


${'minute_read' @ i18n, format=[minutes]}

en_US key value [sling:message] can be like:    {0} minutes 

No comments:

Post a Comment