I am trying to access the children of another template and can't. What I mean is: there are a few templates at level 2 - they are all under the Master. One is called CEO and under this the monthly reports from the CEO are written. There is another called Old Reports where we want a full list of all the reports written by the CEO. I have tried this:
<div class="column w300 gut10">
@foreach(var page in CurrentPage.Parent.Children) { HtmlString pain = new HtmlString(""); foreach(var apage in page.Children) {
After leaving it for the night I came up with this:
@foreach(var page in CurrentPage.AncestorOrSelf(1).Children) {
foreach(var apage in page.Children) { <p>@apage.Name</p>
}
} It almost works, I'm getting a list of the grandchildren's names. So I need a specific set, the CEO's. I can't figure out how to use the .Where as when I do it all goes blank!
How can I access the children of another template
Hi All
I am trying to access the children of another template and can't. What I mean is: there are a few templates at level 2 - they are all under the Master. One is called CEO and under this the monthly reports from the CEO are written. There is another called Old Reports where we want a full list of all the reports written by the CEO. I have tried this:
<div class="column w300 gut10">
@foreach(var page in CurrentPage.Parent.Children)
{
HtmlString pain = new HtmlString("");
foreach(var apage in page.Children)
{
pain= @apage.summary;
}
<div class="box">
<div class="section">
<span style="line-height: 1.4em; font-size: 16px; font-weight: bold;">@page.Name</span>
</div>
<div class="section">
<p>@page.CEOContent</p>
<p><a class="buttonGrey block w130" target="_blank" [email protected] rel="nofollow">
@page.Name
<span class="arrow">></span>
</a>
</p>
</div>
</div>
}
</div>
This is giving me a list of all the Level 2 pages. The CEO's reports are one level below them.
Hope this makes sense.....
Thanks
Tony
Hi Tony,
If all of the CEO reports are of a unique document type then you can do something like this:
The document type alias is "myCEODocType"
Jeavon
Hi Tony,
Edited the above as it seems the magic pluraliser is not working in this context.
Jeavon
Hi Jeavon
Thanks, but no joy. I'm just getting a blank page. At least it's not falling over!
I'll try again tomorrow, been at this way too long now!
Thanks.
Tony
Hi Tony,
Maybe try the below, it will make sure it's always getting nodes from the whole current tree.
Jeavon
Hi Jeavon
After leaving it for the night I came up with this:
@foreach(var page in CurrentPage.AncestorOrSelf(1).Children)
{
foreach(var apage in page.Children)
{
<p>@apage.Name</p>
}
}
It almost works, I'm getting a list of the grandchildren's names. So I need a specific set, the CEO's. I can't figure out how to use the .Where as when I do it all goes blank!
So close, no cigar....yet!
Thanks.
Tony
Hi Jeavon
Got it
@foreach(var page in CurrentPage.AncestorOrSelf(1).Children.Where("DocumentTypeAlias == \"ceoAlias\""))
{
foreach(var apage in page.Children)
{
<p>@apage.Name</p>
}
}
That was pretty epic!
Thanks for your help.
Tony
Great you got it!
is working on a reply...
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.