Copied to clipboard

Flag this post as spam?

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


  • Mygel 9 posts 40 karma points
    May 28, 2014 @ 07:49
    Mygel
    0

    Display Children nodes

    Hey Forum, 

    I've been getting the hang out Umbraco and I'm beginning to like it. I have a problem i;ve been trying to solve for quite a while now and need help.

    My Content tree looks like this:

    .Homepage
    ..........Articles
    .................... Blog Post #
    .................... Blog Post #
    .................... Blog Post #
    .................... Blog Post #
    .................... Blog Post #
    ..........More Content
    ..........More Content

    I would like to take the 'Blog Post #' and list them on 'Homepage'.  I've been following the UmbracoTV guide and have been trying to edit this code:
    http://pastebin.com/RyKHdFez

    However my Homepage keeps displaying 'Content', 'More content', and 'Articles' on my Homepage rather than my children nodes! If someone could help this would save my hair. Thanks!

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    May 28, 2014 @ 08:13
    Jeavon Leopold
    0

    Hi and welcome to Our!

    Does "Articles" have a unique document type?

    Jeavon

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    May 28, 2014 @ 10:29
    Jeavon Leopold
    0

    For a fixed id (1234):

    @{
        var articles = Umbraco.Content(1234).Children.Where("Visible");
        foreach (var article in articles)
        {
            <li>
                <a href="#"><img src="http://placehold.it/600x450"></a>
                <h2><a href="@article.Url">@article.Name</a></h2>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
            </li>
        }
    }
    

    For a unique document type:

    @{
        var articles = CurrentPage.AncestorOrSelf(1).Descendant("myArticlesDocType").Children.Where("Visible");
        foreach (var article in articles)
        {
            <li>
                <a href="#"><img src="http://placehold.it/600x450"></a>
                <h2><a href="@article.Url">@article.Name</a></h2>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
            </li>
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft