Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jon 47 posts 290 karma points
    Sep 27, 2017 @ 14:37
    Jon
    0

    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...

  • Martin Aguirre 42 posts 210 karma points
    Sep 27, 2017 @ 15:31
    Martin Aguirre
    0

    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",

  • Kevin Jump 2342 posts 14889 karma points MVP 8x c-trib
    Sep 27, 2017 @ 15:32
    Kevin Jump
    0

    Hi

    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.

  • Jon 47 posts 290 karma points
    Sep 27, 2017 @ 18:22
    Jon
    0
    .UrlAbsolute()
    

    Made it :-)

  • Kevin Jump 2342 posts 14889 karma points MVP 8x c-trib
    Sep 27, 2017 @ 18:34
    Kevin Jump
    0

    yeah - i was doing it from memory : ) (badly it turns out)

Please Sign in or register to post replies

Write your reply to:

Draft