Copied to clipboard

Flag this post as spam?

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


  • Marco Pietersen 6 posts 27 karma points
    Feb 24, 2012 @ 13:11
    Marco Pietersen
    0

    Umbraco 5 - Template for document types

    Hello, 

    I just started and descided to go with Umbraco v5 for my site. 

    I've created a Master document type, a Home document type and a TextPage document type. As I understand from video's I create a template called Layout that holds the site framework (header/footer etc.)
    I then create a subTemplate called Home. I also create a template for TextPage. 
    Now when I create the content for my Home, it uses the Layout and Home templates. All fine. 
    But I also have the TextPage document type that contains blocks of texts.

    In the content I can add the Home-page and add 2 TextPage-pages. 
    How do I get the content (layout and content variables) of both textpages to appear in the Home? 
    Do I use code? Or can it be done easier??

    I've tried somethings, but it's very hard without examples. 
    I came to this:

              @foreach (var item in DynamicModel.Descendants)
              {
                  <label for="@item.Name">@item.Name</label> <br/>
                  <label for="@item.Url">@item.Url</label> <br/>
                  <!--<label for="@ item.Field">Field: @ item.GetPropertyValue("headerText", false)</label> <br/>-->   
          }

    But how do I read the properties from Descendants? 
    (and what objecttype is Descendants?)

  • Marco Pietersen 6 posts 27 karma points
    Feb 24, 2012 @ 17:03
    Marco Pietersen
    0

    After looking through the forum the rest of the afternoon, this became my solution:

            @foreach (var item in DynamicModel.Children)
            {
                <h3>@item.headerText</h3>
                <article>
                    @Html.Raw(@item.bodyText)
                </article>
            }

    So you don't need to create a template for the sub-content, you just rip the fields and it works! 

Please Sign in or register to post replies

Write your reply to:

Draft