Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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><a href="#">Email this</a></li> <li>|</li> <li><a href="#">Subscribe to this feed</a></li> <li>|</li> <li><a href="#">Share on LinkedIn</a></li> <li>|</li> <li><a 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><a href="#">Email this</a></li> <li>|</li> <li><a href="#">Subscribe to this feed</a></li> <li>|</li> <li><a href="#">Share on LinkedIn</a></li> <li>|</li> <li><a href="#">Tweet this</a></li> </ul> </div> } }
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
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.
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
The articles are the "Blog" document type. and the "Blog Container" is the document type of the blog page itself
Oh am sorry the screenshot is what it is supposed to look like.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
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><a href="#">Email this</a></li>
<li>|</li>
<li><a href="#">Subscribe to this feed</a></li>
<li>|</li>
<li><a href="#">Share on LinkedIn</a></li>
<li>|</li>
<li><a 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><a href="#">Email this</a></li>
<li>|</li>
<li><a href="#">Subscribe to this feed</a></li>
<li>|</li>
<li><a href="#">Share on LinkedIn</a></li>
<li>|</li>
<li><a href="#">Tweet this</a></li>
</ul>
</div>
}
}
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:
-Tom
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.
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
The articles are the "Blog" document type. and the "Blog Container" is the document type of the blog page itself
Oh am sorry the screenshot is what it is supposed to look like.
is working on a reply...