I need a list of children from a specific Doctype and i am thinking that i can use a "if" statement to solve the problem. But i have not been able to make it work. Is it wrong to use a "if" statement like this one below:
if (page.NodeTypeAlias == "referencesRoot")
If it is the way to do it where in the code below should i put this "if" statement to make it work proberly?
@{ @*Get the root of the website *@ var root = Model.AncestorOrSelf(3); } @foreach (var group in Model.Children.InGroupsOf(4)) { <div class="row"> @foreach (var page in group) { <div class="span3"> <div class="service-overview"> <h5><span class="link-white"><a href="@page.Url">@page.headerMain</a></span></h5> <p>@(Library.Truncate(Library.StripHtml(page.mainText), 60, true))</p> <img src="@page.image" alt="" /> <div class="service-overview-overlay">+</div> </div><!-- end .service-overview --> </div><!-- end .span3 --> } </div><!-- end .row --> <br /> }
@{ <ul> @foreach(dynamic n in Model.AncestorOrSelf(1).Descendants("referencesRoot").Where("!umbracoNaviHide")){ <li><a hrfe="@n.Url">@n.Name</a> // Here you should get the folder name "Arbejdsomrader" @if(n.Count()>0){ // Mmake some test to see if any children "Forside" <ul> @foreach(var page in n.Children.Where("Visible")){ <li>@page.Name</li> } </ul> } </li> </ul> }
Show children from a specific Doctype
Hi
I need a list of children from a specific Doctype and i am thinking that i can use a "if" statement to solve the problem. But i have not been able to make it work. Is it wrong to use a "if" statement like this one below:
if (page.NodeTypeAlias == "referencesRoot")
If it is the way to do it where in the code below should i put this "if" statement to make it work proberly?
Thanks in advance!
//René
Hi Rene,
You could either do something like
or
Hi Fuji,
Could you please try to put it in the code example that I posted, because I am a rookie in Razor. :-)
I have tried to replace:
With your examples but it tells me "Script error".
Thank you!
//René
Yes Could you please explain how you have your content set ?
Of course, here you are:
Hope it helps
//Fuji
Hi Fuji
I did not manage to get it working but i found a new solution which is working for this project. Thank you for your time and help. :-)
See my solution below:
@{
// Get root node:
var root = Model.AncestorOrSelf();
// Get all descendants, filter by type:
var nodes = root.Descendants("ServiceSingleFrontpage");
// Loop through the filtered nodes, displaying the properties:
<div class="row">
@foreach (var page in nodes)
{
<div class="span3">
<div class="service-overview">
<h5><span class="link-white"><a href="@page.Url">@page.headerMain</a></span></h5>
<p>@(Library.Truncate(Library.StripHtml(page.mainText), 60, true))</p>
<img src="@page.image" alt="" />
</div><!-- end .service-overview -->
</div><!-- end .span3 -->
}
</div>
}
//René
Hi Rene,
Good you got it workin, just one thing you could do to save some line of code
Hi Fuji
Thank you! Nice to clean up the code.
//René
is working on a reply...