Expand my Community achievements bar.

SOLVED

data-sly-call clientLib Absolute URL

Avatar

Level 1

Is there anyway to output the clientLib resources as absolute urls?

EXAMPLE CODE

<output data-sly-call="${clientLib.all @ categories='cq.jquery'}"  data-sly-unwrap></output>

CURRENT OUTPUT

<script type="text/javascript" src="/etc/clientlibs/granite/jquery.js"></script>
<script type="text/javascript" src="/etc/clientlibs/granite/utils.js"></script>
 

WANTED OUTPUT

<script type="text/javascript" src="http://MYSITE.COM/etc/clientlibs/granite/jquery.js"></script>
<script type="text/javascript" src="http://MYSITE.COM/etc/clientlibs/granite/utils.js"></script>

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi,

you can implement your own rewriter [1], which rewrites certain URLs to include the full hostname. Or you can implement mod_proxy on the calendar system to fetch the data from AEM instead.

kind regards,
Jörg

 

[1] https://sling.apache.org/documentation/bundles/output-rewriting-pipelines-org-apache-sling-rewriter....

View solution in original post

5 Replies

Avatar

Employee Advisor

Hi,

in that case it might be easiest approach to customize the rewriter, so you can externalize these URLs. By default they are relative, which is normally a good idea. Why do you want to have a hostname in this URLs?

kind regards,
Jörg

Avatar

Level 8

Hey Mikal, given what you're trying to do the best option would be to make the CSS files available in the DAM.  When you activate the CSS file from the DAM the cache will be cleared on the dispatcher and your external application will receive the latest, most up to date file.  If you do something like you're trying to accomplish, you'll have to clear the dispatcher cache manually when you need to update your external application (because /etc/ does not get flushed) - not to mention that writing a custom rewriter to provide this functionality is a lot of work for no gain.

Avatar

Level 1

Thanks for the response. 

The reason I was looking to have the hostname in the URLs, is that we are integrating our website with a 3rd party calendar system.  The calendar requires a template shell that they draw into their site around the calendar functionality (subdomain.website.com).  This template shell requires that any resources (CSS/JS/Images) have hard coded urls to point back to the actual file location, and not relative url.

I was hoping to create an AEM template for the shell based upon our existing templates, that would automatically update with any code changes.  For example, drawing in the header, footer, navigation, and resources.  This way we won't need to make duplicate modifications to the shell template when we update our site, since it will automatically happen.

Long story short, I was trying to come up with a way to avoid making redundant changes on templates, specifically those created for 3rd party integrations. 

Does that make sense?

Avatar

Level 1

Thanks Lee.  I will just hard code the files urls in for now, and try to remember to change them manually if/when we change them.

Avatar

Correct answer by
Employee Advisor

Hi,

you can implement your own rewriter [1], which rewrites certain URLs to include the full hostname. Or you can implement mod_proxy on the calendar system to fetch the data from AEM instead.

kind regards,
Jörg

 

[1] https://sling.apache.org/documentation/bundles/output-rewriting-pipelines-org-apache-sling-rewriter....