Copied to clipboard

Flag this post as spam?

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


  • Tara Pattenden 44 posts 205 karma points
    Oct 08, 2020 @ 07:16
    Tara Pattenden
    0

    rendering doctypes that are not children in a different template

    Hi

    I have a doctype called program that is a child of doctype programs. There are many content nodes using the program doc type - they are all children of programs content node.

    I would like to show the same program content nodes in another template(doctype) in my site called live-on-the-line. It is a sibling of programs.

    Is it possible to list items and their model properties if they are not a child of the doc type?

    Here is what I am trying. I do not get any errors from intellisense but no content appears. I can see the properties in intellisense but it doesn't seem I am linking to the actual content nodes. How do I do this?

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<LiveOnTheLine>
    
    @{
        Layout = "Master.cshtml";
    }
    
    <section>
    @{
        var progList = Model.Siblings<Programs>()
            .Where(x => x.IsVisible());
    
        var progTest = Model.Children<Program>();
    }
    <ul>
        @foreach (var prog in progTest)
        {
            <li>
                @prog.MainProgramDescription
            </li>
        }
    </ul>
    

    Thanks

  • Steve Morgan 1345 posts 4452 karma points c-trib
    Oct 09, 2020 @ 12:32
    Steve Morgan
    101

    Hi,

    I think you have a slight bug.. what you need to do is get all of the progList (which you've done) and then loop through these and then inside that loop loop out the programs.

    It will likely be something along the lines of:

        @inherits Umbraco.Web.Mvc.UmbracoViewPage<LiveOnTheLine>
    
    @{
        Layout = "Master.cshtml";
    }
    
    <section>
    @{
        var progList = Model.Siblings<Programs>()
            .Where(x => x.IsVisible());
    
        foreach(var progTest in progList)
        {
    
            <ul>
                    @foreach (var prog in progTest)
                    {
                        <li>
                            @prog.MainProgramDescription
                        </li>
                    }
            </ul>
        }
    

    }

  • Tara Pattenden 44 posts 205 karma points
    Oct 11, 2020 @ 00:43
    Tara Pattenden
    0

    great! thanks for this, sometimes it's the small things that are the issue.

  • Steve Morgan 1345 posts 4452 karma points c-trib
    Oct 12, 2020 @ 09:13
    Steve Morgan
    0

    Glad it's sorted! Sometimes you can stare a problem for too long. Rubber ducking or posting of forums often clears the blockage - happy to help!

    Steve

Please Sign in or register to post replies

Write your reply to:

Draft