Links generated by kentico can they be absolute links

Kentico User asked on February 23, 2016 22:59

Hi,

Any system link, like the style-sheet link generated by kentico can that be an absolute link instead of a relative link? Is there a setting that can be changed?

Thank you,

Recent Answers


Trevor Fayas answered on February 25, 2016 16:06

I don't see a setting that allows for absolute URLs, and the code for this may be in different locations (different web parts mainly).

Two options then: If the urls must be proper from the server (server side logic), what i would do is use the CMS Modules to create a setting (say "use Absolute") and a setting for the absolute domain name, and then wherever you need the absolute url to appear clone and modify that tool to use the specified domain name before hand. Perhaps putting the logic in a function that handles both the "Should i use the absolute url or not" and what one it uses, so you just call that function beforehand.

If you are okay with doing it client side (javascript) you can write up a pretty easy jQuery catch to look for all href's or src attributes and if it doesn't have http then append it.

Something like $("*[href]:not([href^='http'])").attr("href", "http://mydomain.com/"+$(this).attr("href"));

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.