Copied to clipboard

Flag this post as spam?

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


  • Paul 18 posts 159 karma points
    Nov 20, 2017 @ 12:41
    Paul
    0

    Related Links unexpected Guids - convert these to Url?

    I can't get my head around this.

    Why do some of my pages return proper urls and some return GUIDs?

    How can I convert a Guid to a url? I've seen some posts but none seem to work.

    Really appreciate help with this one. It's all over the place in my application.

    @}
        var quickLinks = child.GetPropertyValue<RelatedLinks>("quickLinks");
    }
    
    <ul>
        @foreach (var link in quickLinks)
        {
            <li><a href="@link.Link">@link.Caption</a></li>
        }
    </ul>
    

    Resulting HTML:

    <ul>
        <li><a href="umb://document/f1904dceef1f406f94aa5561bf3fa5c8">Bid on a property</a></li>
        <li><a href="/rent-or-buy/private-home-rental/">Private home rental</a></li>
        <li><a href="umb://document/cbcc1d8252ae4aa99b833570ba6654b0">New build homes</a></li>
        <li><a href="umb://document/3b3972e3bd684b41b79ab6e73da42519">Rent a garage</a></li>
        <li><a href="/rent-or-buy/shared-ownership/">Shared ownership</a></li>
        <li><a href="umb://document/06407757d4e74df4a852d75baba79e30">Supported living</a></li>
    </ul>
    
  • Steve Morgan 1345 posts 4452 karma points c-trib
    Nov 20, 2017 @ 13:59
    Steve Morgan
    1

    Hmm...

    I wonder if it's a conflict of model name.. try:

    @{
        var quickLinks = Model.Content.GetPropertyValue<Umbraco.Web.Models.RelatedLinks>("quickLinks");
    
        <ul>
            @foreach (var link in quickLinks)
            {
                <li><a href="@link.Link">@link.Caption</a></li>
            }
        </ul>
    }
    
  • Alex Skrypnyk 6131 posts 23950 karma points MVP 7x admin c-trib
    Nov 20, 2017 @ 15:34
    Alex Skrypnyk
    0

    Hi Paul and Steve

    What version of Umbraco are you using?

    Is there any difference between links that are working and that returns udis?

    Can you try this code:

    @foreach (var link in quickLinks)
        {
            if (link.IsInternal)
            {
                <li><a href="@link.Content.Url">@link.Caption</a></li>
            }
            else
            {
                <li><a href="@link.Link">@link.Caption</a></li>
            }
        }
    

    Thanks,

    Alex

  • Paul 18 posts 159 karma points
    Nov 20, 2017 @ 17:12
    Paul
    0

    Thanks for your replies gents, really appreciate them.

    I looked into the differences between the links as per Alex's advice and it turns out:

    The pages which were showing UDIs didn't have a 'Publish at' date in the properties tab so, not yet knowing the internals of Umbraco's publishing, it looks like they weren't 'published'.

    Setting a publish at date of today meant the correct url pulled through to the link (not the URI).

    Weirdly, I can still visit these pages on the front end via the page url (they show fine) so i'm not sure why they aren't counted as published - this would have given me an obvious smell and clue.

    Best, Paul

  • Alex Skrypnyk 6131 posts 23950 karma points MVP 7x admin c-trib
    Nov 20, 2017 @ 17:17
    Alex Skrypnyk
    1

    Hi Paul

    I think Nexu package can help you to track unpublished nodes - https://our.umbraco.org/projects/backoffice-extensions/nexu/

    If you can visit the pages then they were published before and just continue to work, but agree with you that this is strange

    Thanks,

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft