Copied to clipboard

Flag this post as spam?

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


  • Babajide 26 posts 46 karma points
    Aug 22, 2012 @ 18:24
    Babajide
    0

    Macro not pulling child nodes

    I have an "Agriculture" page that is an ancestor to a Blog page. The blog page contains some other dynamic pages that am trying to pull to show on the blog page, but it isnt working. Here are some pictures to explain more:

    And here is my code:

    @using Examine;
    @using umbraco.MacroEngines;
    @using System.Text.RegularExpressions;

    @{
        var name @Model.BlogContainer[0];
                                
     }
        @foreach (var item in @name.Blog)
         {
            try{
            var resourceSearchSummary @item.Image;
            dynamic mediaItem new DynamicMedia(resourceSearchSummary.ToString());  
                                
                 <div class="fiveeasiatways">
                  <img src="@mediaItem.umbracoFile" alt="">  
                   <h1>@item.title</h1>
                    <h2>@item.author</h2>
                    <p>
                       @item.bodyText 
                      </p>
                       <ul class="simplalulli">
                        <li><href="#">Email this</a></li>
                        <li>|</li>
                        <li><href="#">Subscribe to this feed</a></li>
                         <li>|</li>
                         <li><href="#">Share on LinkedIn</a></li>
                         <li>|</li>
                         <li><href="#">Tweet this</a></li>
                        </ul>
                   </div>          
                }
           catch{
                 <div class="fiveeasiatways">
                    
                   <h1>@item.title</h1>
                    <h2>@item.author</h2>
                    <p>
                       @item.bodyText 
                      </p>
                       <ul class="simplalulli">
                        <li><href="#">Email this</a></li>
                        <li>|</li>
                        <li><href="#">Subscribe to this feed</a></li>
                         <li>|</li>
                         <li><href="#">Share on LinkedIn</a></li>
                         <li>|</li>
                         <li><href="#">Tweet this</a></li>
                        </ul>
                   </div>         
                 }
                
              
                                                            
         }
      

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 22, 2012 @ 20:49
    Tom Fulton
    0

    Hi,

    I think you might want to adjust your for each loop to loop through the Blog's Children nodes, is that right?

    Something like:

    @foreach (var item in @name.Blog.Children)

    -Tom

  • Babajide 26 posts 46 karma points
    Aug 22, 2012 @ 21:11
    Babajide
    0

    Not exactly. The page with the Blog icon is the page i want the articles (the red diamond icons) to appear on. The articles dont have any children.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 22, 2012 @ 21:17
    Tom Fulton
    0

    Hmm, I'm probably misunderstanding - based on the screenshots it looks like you already have the two child articles showing on the Blog page.

    Is the code above what you're using on the actual Blog page?  I think the foreach should be foreach (var item in Model.Children) in that case

  • Babajide 26 posts 46 karma points
    Aug 22, 2012 @ 21:19
    Babajide
    0

    The articles are the "Blog" document type. and the "Blog Container" is the document type of the blog page itself

  • Babajide 26 posts 46 karma points
    Aug 22, 2012 @ 21:20
    Babajide
    0

    Oh am sorry the screenshot is what it is supposed to look like.

Please Sign in or register to post replies

Write your reply to:

Draft