Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 886 posts 2415 karma points
    Oct 21, 2014 @ 14:04
    Claushingebjerg
    0

    attaching currentpage url to domain

    Im doing a simple facebook share button, but experince something weird

    href="https://www.facebook.com/sharer/sharer.php?u=http://www.mydomain.dk/@CurrentPage.Url

    returns almost correctly http://www.mydomain.dk//mypage/
    but with two // between the domain and page url.

    href="https://www.facebook.com/sharer/sharer.php?u=http://[email protected]
    Any idea how i get http://www.mydomain.dk/mypage/ ?

     

  • Dan Lister 416 posts 1973 karma points c-trib
    Oct 21, 2014 @ 14:23
    Dan Lister
    100

    Hi,

    You could try the following. You'll probably want to encode the Url too.

    href="https://www.facebook.com/sharer/[email protected](CurrentPage.UrlWithDomain())
    

    Thanks, Dan.

  • Claushingebjerg 886 posts 2415 karma points
    Oct 21, 2014 @ 14:34
    Claushingebjerg
    0

    That did the trick, but can someone explain why my razor example doesnt run unless there's a / or a space before the @

    xxxxx @Currentpage.Url or xxxx/@Currentpage.Url works, whereas [email protected] doesnt...

    how should one write this? i can think of a million other cases where this could be useful.

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Oct 21, 2014 @ 14:36
    Alex Skrypnyk
    0

    Hi, Claus,

    Try to use NiceNameFullPath.

    http://our.umbraco.org/wiki/reference/umbracolibrary/niceurlfullpath

    Thanks

  • Dan Lister 416 posts 1973 karma points c-trib
    Oct 21, 2014 @ 14:39
    Dan Lister
    0

    I'm not quite sure why it wouldn't work. You could try using string.Format() if you are having issues with your syntax. For example...

    var url = string.Format("https://www.facebook.com/sharer/sharer.php?u={0}", HttpUtility.UrlEncode(CurrentPage.UrlWithDomain()))
    <a href="@url">...</a>
    

    Thanks, Dan.

  • Claushingebjerg 886 posts 2415 karma points
    Oct 21, 2014 @ 14:41
    Claushingebjerg
    0

    Thanks Alex, but thats xslt

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Oct 21, 2014 @ 14:52
    Alex Skrypnyk
    0

    Sorry method is obsolete, but still working

    var url = library.NiceUrlWithDomain(nodeId);
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies