Model.Site()(or Model.Content.Site() depending on what template/partial you are in) will return the root site element for the current page.
var root = Model.Site();
but if you just want to ensure that things keep the URL across the site, you should be able to call Model.AbsoluteURL() - and get the URL with the host name for a page or object.
Root path / Site url – does it exist?
Hi :-)
I'm looking for a global variable like @siteUrl or @rootPath - or what ever it could be named.
It's to get en root url like the domain or localhost.
Ex. I have images that are linked to media – but they wont show when I go levels down in navigation...
Hi Jon.
In the .cshtml file (the view) can use the DOM elements in Js.
e.x.
Get the location
var jqxhr = $.getJSON( window.location.href + "/umbraco/api/Currency/GetCurrencyExchange",
Another way (also support non root location)
var jqxhr = $.getJSON( document.location.origin + "/" + location.pathname.split('/')[1] + "/umbraco/api/Currency/GetCurrencyExchange",
Hi
Model.Site()
(orModel.Content.Site()
depending on what template/partial you are in) will return the root site element for the current page.but if you just want to ensure that things keep the URL across the site, you should be able to call
Model.AbsoluteURL()
- and get the URL with the host name for a page or object.Made it :-)
yeah - i was doing it from memory : ) (badly it turns out)
is working on a reply...