Only display child node if the DocumentTypeAlias is equal to
Hi there, I have a parent node with 2 different types of child nodes.
About
--Bio 1 (Child node type 1)
--Bio 2 (Child node type 1)
--FAQ 1 (Child node type 2)
--FAQ 2 (Child node type 2)
What I want to do is only display one type of child node ie if the child node document type is == to "fAQ" show FAQ
@{ var selection = CurrentPage.Children.Where("Visible") && Model.Content.DocumentTypeAlias == "fAQ"; }
@{ var i = 1; }
@foreach (var item in selection)
{
<p>Hello I am an FAQ child node</p>
i+=1;
}
My problem is coming from the Model.Content.DocumentTypeAlias == "fAQ"; i think...
I cant figure this one out for the life of me. Any help is appreciated.
@{ var selection = Umbraco.AssignedContentItem.Children.Where(x => x.IsVisible() && x.DocumentTypeAlias.Equals("fAQ")); }
@{ var i = 1; }
@foreach (var item in selection)
{
<p>Hello I am an FAQ child node @item.Name</p>
i+=1;
}
Model.Content.DocumentTypeAlias == "fAQ" is wrong, because Model.Content - it's current page, so you check is current page FAQ?
Thanks for your input. I implemented that code you provided and could not get it to run properly
I ended up using this code which worked for me. (Not as slick as your solution but it worked)
@{ var selection = CurrentPage.Children.Where("Visible"); }
@{ var i = 0; }
@foreach (var item in selection)
{
if(item.DocumentTypeAlias == "fAQ"){
<p>Hello I am an FAQ child node @item.Name</p>
}
i += 1;
}
Only display child node if the DocumentTypeAlias is equal to
Hi there, I have a parent node with 2 different types of child nodes.
About
--Bio 1 (Child node type 1)
--Bio 2 (Child node type 1)
--FAQ 1 (Child node type 2)
--FAQ 2 (Child node type 2)
What I want to do is only display one type of child node ie if the child node document type is == to "fAQ" show FAQ
My problem is coming from the Model.Content.DocumentTypeAlias == "fAQ"; i think...
I cant figure this one out for the life of me. Any help is appreciated.
To simplify the question: How do you only show a child nodes that have a certain name?
Hi Lee
Use this code:
Model.Content.DocumentTypeAlias == "fAQ" is wrong, because Model.Content - it's current page, so you check is current page FAQ?
Thanks,
Alex
Hi Lee
Did you solve the issue?
Alex
Hi Alex,
Thanks for your input. I implemented that code you provided and could not get it to run properly
I ended up using this code which worked for me. (Not as slick as your solution but it worked)
I would have thought perhaps something along these lines...?
is working on a reply...