0

I'm new to Sightly and AEM development and I'm trying to concatenate the following string href to play a video in a lightbox or open a PDF in a new window. As I'm trying to get this to work any suggestions would be greatly appreciated.

 <sly data-sly-test="${details.videoPlayingOptions != 'vlp-video'}">
      <a href="${details.pagePath} || '#' || '${gatherInsight.videoLandingPagePath}?vid=${details.videoID}'" class="cta-lightbox" data-videoid="${details.videoID}" target="${details.contentType == 'PDF' ? '_blank' : '_self'}">${details.title}</a>
 </sly>

Thank you

Vlad
  • 10,602
  • 2
  • 36
  • 38
Reading_code
  • 21
  • 1
  • 8

1 Answers1

2

String concatenation is not done in HTL/Sightly with || as your code attempts, that's only used for logical OR.

You should use the URI manipulation options as it makes your code more readable:

href="${details.pagePath @ fragment=gatherInsight.videoLandingPagePath, query=details.videoIDQuery, context='uri'}"

If adding the query map to your use object is not an option you can attempt to concatenate the string using data-sly-test:

data-sly-test.videoURL="${details.pagePath}#${gatherInsight.videoLandingPagePath}?vid=${details.videoID}" href="${videoURL @ context='uri'}"
Vlad
  • 10,602
  • 2
  • 36
  • 38