Copied to clipboard

Flag this post as spam?

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


  • Pete 213 posts 285 karma points
    Nov 28, 2012 @ 17:12
    Pete
    0

    External Link Url Bug 4.9+

    I've got a external link property in my navigation script, and stored the external url as textstring.

    When it gets rendered, it renders as:

    www.mydomain.com/www.google.com

    instead of www.google.com

    i've tried without the www, and with the http:// but nothing seems to work, it always puts the domain in front.

    I know ucomponents has a type for this, but what about in standard umbraco? is this a bug?

    Thanks, Pete

  • Stephen Davidson 216 posts 392 karma points
    Nov 28, 2012 @ 17:45
    Stephen Davidson
    0

    Can we see the navigation script and even the live page?...i've seen this happen when there is no "http://" but you say you have tried it with this?

    S

  • Pete 213 posts 285 karma points
    Nov 28, 2012 @ 17:50
    Pete
    0

    Sorry no live page.

    Here's the outputed html

    <li><a href="www.google.com">/ An Example Link</a></li>

    This is how the browser processes it:

    www.mydomain.com/www.google.com

    Here's my nav code:

    <ul class="drop-down">
      @foreach (var item in Model.Children.Where("Visible")) {
                                var hrefer = @item.Url;
                                if(item.NodeTypeAlias == "externalLink"){
                                    hrefer = @item.linkUrl.Url;
                                }
                                <li><a href="@hrefer">/ @item.Name</a></li>
       }
     </ul>


    #Confused!

  • Pete 213 posts 285 karma points
    Nov 28, 2012 @ 18:05
    Pete
    0

    If you build the string like:

    hrefer = "http://" + @item2.linkUrl.Url;

    It works, but not if you put "http://www.google.com" into the textstring field.

  • Stephen Davidson 216 posts 392 karma points
    Nov 28, 2012 @ 18:16
    Stephen Davidson
    0

    I'm probably being stupid here but you have two options

    1. Ensure the user in putting in the external url as www.google.com only and at the http:// to the string in code
    2. Ensure the user puts in the external url as http://ww.google.com and use the string as is
    Either way you always need the HTTP:// ;
    Also should the code not be the following if its a text string?
    @item.linkUrl
    S
  • 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