Check if a child page is published and has a certain document type
Hi,
I need some help with an 'if statement', I've tried looking for and working out a solution with no luck:
I have multiple 'home pages', and have various child pages sitting underneath, like;
homepage 1
child page 1 (doc type 1)
child page 2 (doc type 2)
child page 3 (doc type 3)
homepage 2
child page 1 (doc type 1)
child page 2 (doc type 2)
child page 3 (doc type 3)
On the homepage template, I'm dynamically pulling in content from one of the child pages (child page 3 with the doc type 3),
IF STATEMENT TO WRAP AROUND HERE
@{
var rootOfTree = Model.AncestorOrSelf(1); @* Get root node of tree *@
var makingChangeSelection = rootOfTree.Children
.Where(x => x.ContentType.Alias == "makingTheChange")
.Where(x => x.IsVisible()).First() @* Get first visible child of makingTheChange *@
.Children("makingTheChangeStory").Where(x => x.IsVisible() && x.Value<string>("storyCategory") == "Story"); @* Then get all story children that are visible *@
@* Foreach story, get the latest 4 *@
foreach(var story in makingChangeSelection.OrderByDescending(x => x.CreateDate).Take(4)){
<div class="pure-u-1-2 pad-10 text-center">
@Html.Partial("Components/Widgets/Img Caption Small", story)
</div>
}
}
IF STATEMENT TO WRAP AROUND HERE
I want to create an if statement around that piece of code to first check if that doctype is published/visible before running the code, is this possible?
I hope that makes sense, and hope somebody can help me out with this :)
Check if a child page is published and has a certain document type
Hi,
I need some help with an 'if statement', I've tried looking for and working out a solution with no luck:
I have multiple 'home pages', and have various child pages sitting underneath, like;
On the homepage template, I'm dynamically pulling in content from one of the child pages (child page 3 with the doc type 3),
I want to create an if statement around that piece of code to first check if that doctype is published/visible before running the code, is this possible?
I hope that makes sense, and hope somebody can help me out with this :)
is working on a reply...