Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Social Media Share Buttons with Sightly

Avatar

Level 2

Hello,

I am developing a Sightly component that contains the various social media share button plugins. I am trying to pass in the current page using:

${currentPage.path @ context='uri'}.html

This is not working for me as I would expect however. I am seeing the AEM path to the page (http://www.mysite.com/content/sites/en/news...) rather that the live link (http://www.mysite.com/news...).

This is how I am implementing the plugin (here's a LinkedIn example):

<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang: en_US</script> <script type="IN/Share" data-url="${currentPage.path @ context='uri'}.html"></script>

Could you please advise on how to correct this issue?

Thanks, Matt

4 Replies

Avatar

Level 9

Hi Matt,

I think you might find more help regarding use of Sightly in the AEM seciton of the forum, so I'm moving this.

- JK

Avatar

Level 8

What you're seeing is actually the correct behavior.  ${currentPage.path} is the full /content/sites/en/news path, however, it shows up differently on the dispatcher facing site as "http://www.mysite.com/news" because of either a) dispatcher rewrites or b) sling mappings.

Do you know whether your URL's are rewritten at the dispatcher level, or the AEM level?

Avatar

Level 2

We are doing re-writes at the dispatcher level, but there are some mappings in Sling. What I'm unclear on is setting the context to uri.

If I do this <a href="${currentPage.path}"></a> then the url gets rewritten correctly.

Why doesn't <p>${currentPage.path @ context='uri'}</p> do the same thing? Aren't I explicitly declaring the context of the expression an href / src?

Avatar

Level 8

It's because your dispatcher rewrites are only setup to rewrite anchor tags, image sources and possibly form actions.  This is pretty normal.

I don't believe there is a way you can mimic the dispatcher URL without forcibly just replacing "/content/site/en" in the string before you output it.