Hello
Is it possible to get the hostname of the current page?
currentPage.getPath() only returns something like '/path/path/page' but I also need to find the hostname, for example, 'https://www.google.com'
Is it possible? Or is there a good way of doing it?
Solved! Go to Solution.
Views
Replies
Total Likes
Yes, it's possible. Check out the Externalizer service [0] for access to the hostname, and the Sightly Use-API [1] for exposing that value to your Sightly scripts.
[0] https://docs.adobe.com/docs/en/aem/6-1/develop/platform/externalizer.html
[1] http://docs.adobe.com/docs/en/aem/6-1/develop/sightly/use-api-in-java.html
Yes, it's possible. Check out the Externalizer service [0] for access to the hostname, and the Sightly Use-API [1] for exposing that value to your Sightly scripts.
[0] https://docs.adobe.com/docs/en/aem/6-1/develop/platform/externalizer.html
[1] http://docs.adobe.com/docs/en/aem/6-1/develop/sightly/use-api-in-java.html
Hi,
I don't think that it is a good idea to attach the hostname (and the protocol as well) to a link when you render a page. At least as long as you don't need to switch either server or protocol. If you stay all the time on https://mysite.com, you should just render relative links.
When you need to switch the hostname, you can use the Externalizer as suggested by Bruce. Or you might implement something custom.
kind regards,
Jörg
Views
Replies
Total Likes
Thanks guys for the advice.
I'm now developing a sharing functionality, for example, click a button from a news page and it fires the Twitter api with the news page url.
Actually, I'm a bit surprised that it requires to modify the console.
Views
Replies
Total Likes
I think you could probably get it easier through the request global object..
${request.serverName}
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies