Copied to clipboard

Flag this post as spam?

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


  • Topic author was deleted

    Sep 01, 2014 @ 16:30

    RelatedLinks in 7.0.4

    Hi,

    I've found some answers regarding RelatedLinks, but they all seem to be using a version around 4.7, and either something has changed with the process since then, or I'm looking for the wrong things.

    I have a doctype which has a data type of Related Links. I want to get these related links and parse through them one by one. If I do:

    @item.GetProperty("informationNuggets").Value
    

    and push that out to a page, I get what looks like a JSON array. However, if I try something like this:

    foreach (var nugget in @item.informationNuggets){}
    

    I get an error, "CS1061: 'Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'informationNuggets' and no extension method 'informationNuggets' accepting a first argument of type 'Umbraco.Core.Models.IPublishedContent' could be found (are you missing a using directive or an assembly reference?)"

    Could someone point me in the right direction for this? I've attached my complete code so far. This is in a Razor template as well, FYI:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    
    @using umbraco.NodeFactory;
    @using umbraco.MacroEngines;
    @{
        Layout = "Master.cshtml";
    }
    
    @section MainContent{
        <h1>@Model.Content.GetProperty("mainHeading").Value</h1>
    
        @{
            var root = Model.Content.AncestorOrSelf();
            var nodes = root.Descendants("HomeSection");
    
            foreach(var item in nodes){
                <div class="section">
                    <h2>@item.GetProperty("title").Value</h2>
                    <p>@item.GetProperty("subTitle").Value</p>
    
                    @{
                        foreach (var nugget in @item.informationNuggets){
                            <p>Working!</p>   
                        }
                    }
                </div>  
            }
        }   
    }
    

    Any advice would be very much appreciated :)

  • Jeavon Leopold 3074 posts 13631 karma points MVP 11x admin c-trib
    Sep 01, 2014 @ 16:47
    Jeavon Leopold
    101

    Hi Ed,

    If you take a look at the documentation for the v7 Related Links picker it has Razor snippets for both dynamic model and the typed one. I would suggest you try the dynamic one.

    I would highly recommend an upgrade to Umbraco v7.1.6 as there are a lot of improvements and fixes since v7.0.4.

    Regards,

    Jeavon

  • Comment author was deleted

    Sep 02, 2014 @ 12:33

    Hi Jeavon,

    Thank you very much for your reply - that documentation was exactly what I was looking for - not sure how I missed that!

    Thanks, Ed

  • Jeavon Leopold 3074 posts 13631 karma points MVP 11x admin c-trib
    Sep 02, 2014 @ 14:45
    Jeavon Leopold
    0

    Np, also if you upgrade to v7.1.6 you will have the option to reorder the related links!

Please Sign in or register to post replies

Write your reply to:

Draft