Copied to clipboard

Flag this post as spam?

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


  • Andreas Grahn 2 posts 72 karma points
    Mar 25, 2020 @ 08:11
    Andreas Grahn
    0

    Reuse template for Document Type Collection

    Hello, I have a question about reusing nested content templates. What I want to do is to be able to create multiple pages where each one has a carousel of images ("MyGarden", "MyHouse").

    I have made a Document Type Collection (CarouselHolder) which in turn has underlying document types (CarouselImage). Then I create a content page called "MyGarden"

    When I then edit the template, I specify which page it should fetch its children (CorouselImages) from. Then I have to enter a specific page (MyGarden) in the query builder. This means that if I create a new carousel page ("MyHouse") then I also have to create a new template first?

    Is it possible to reuse a template in this case so that each Carousel content page uses the same template, but know what images should it should use?

  • Chris Norwood 131 posts 642 karma points
    Mar 27, 2020 @ 15:11
    Chris Norwood
    0

    If I've understood you correctly then your structure has the children for the current node, so you ought to be able to do something like:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<CarouselHolder>
        @{
            var children = Model.Children(); 
        }
    
        @foreach(var carouselImage in children)
        {
            //output carousel image here - add code based on properties of the image
        }
    

    Then you don't need a separate view for the child pages.

    PS, I would usually use something like a multi url picker here instead of having child nodes if you';re just outputting pictures, or if you need more properties like caption/overlay etc. then Nested Content with document type elements can work well.

  • Andreas Grahn 2 posts 72 karma points
    Mar 27, 2020 @ 19:49
    Andreas Grahn
    0

    Hello, and thanks for your answer! I went for the solution of using document type instead which gave me more flexibility (you can use it in any documenttype). I must say, Umbraco is one amazing tool, and this community sure makes up for the reputation of being very friendly! =)

Please Sign in or register to post replies

Write your reply to:

Draft