Copied to clipboard

Flag this post as spam?

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


  • David Christiansen 13 posts 163 karma points
    Feb 20, 2017 @ 10:18
    David Christiansen
    0

    Modelsbuilder and looping through child nodes

    I have started to learn Umbraco recently, and now want to use my MVC skills together with ModelsBuilder. My Issus is that i want to make a About us page, with dynamic content (whoe we are, etc.). I have then created a doctype for employees, that are allowed children for the about us doctype.

    I know how to loop through the children and display the content directly on the about us page, with the "old style" Umbraco (var selection = CurrentPage.Children......) Is there any way to do that with the models created in modelsbuilder, or do i have to add a partial view for that?

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Feb 20, 2017 @ 15:23
    Alex Skrypnyk
    100

    Hi David

    It's the same as for "old style", just add right "inherits" declaration:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<[YourDoctypeModelBuilderClass]>
    

    And get children nodes:

    var children = Model.Children;
    

    I hope it will help you, have a nice evening!

    Thanks,

    Alex

  • David Christiansen 13 posts 163 karma points
    Feb 21, 2017 @ 07:24
    David Christiansen
    1

    Thank you very much Alex! I didn't realise it was going to be that easy :-)

    David

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Feb 21, 2017 @ 09:21
    Alex Skrypnyk
    0

    You are welcome! Have a nice day.

    Alex

  • 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