me thinks this should work if you just want to list all descendants (from what I assume looking at your output) regardless of nested structure
@{ var promoNode = new DynamicNode(<id of Promos node>); var descendants = promoNode.Descendants(); <ul> foreach(var descendant in descendants) { <li>@descendant.Name</li> } </ul> }
Is there a way to do it so that the ID of the node does not need to be input? For example, Self ? s there will be multiple Promo nodes with child pages.
Still not getting the right result. I can't seem to get the 3rd and 4th level items to appear under one nav (as in my example above). When I am on the 3rd level node (i.e. Promo 1 Details), it shows the child nodes but not itself. When I go to the 4th level node (i.e. About or Terms and Conditions), no items are returned.
Razor sidebar nav
Hi,
I need to create a sidebar nav but having a bit of trouble writing it with razor. My content structure is as follows:
- Home-- Promos
--- Promo 1 Details
---- About
---- Terms and Conditions
What I am trying to do is produce a sidebar nav like the below for Promo 1 and for it's child pages
*Promo 1 Details
*About
*Terms and Conditions
Any tips? I know I can do this in XSLT but trying to use Razor instead
Using Umbraco 4.8.1
Cheers,
Bij
Hi Bijesh,
Here you go
@{var StartNode = Model.NodeById(1200);
foreach(dynamic page in StartNode.Children.Where("Visible")){
<li>
@if(page.Children.Count() > 0){
<ul>
@foreach(dynamic childPage in page.Children.Where("Visible")){
if (childPage.Children.Count() > 0) {
<a href="@firstChildUrl">@childPage.Name</a>
}
}
</ul>
}
}
}
HI,
me thinks this should work if you just want to list all descendants (from what I assume looking at your output) regardless of nested structure
@{var promoNode = new DynamicNode(<id of Promos node>);
var descendants = promoNode.Descendants();
<ul>
foreach(var descendant in descendants)
{
<li>@descendant.Name</li>
}
</ul>
}
Cheers,
/Dirk
Is there a way to do it so that the ID of the node does not need to be input? For example, Self ? s there will be multiple Promo nodes with child pages.
yup, use Model.Id (equivalent to $currentPage/@id)
Still not getting the right result. I can't seem to get the 3rd and 4th level items to appear under one nav (as in my example above). When I am on the 3rd level node (i.e. Promo 1 Details), it shows the child nodes but not itself. When I go to the 4th level node (i.e. About or Terms and Conditions), no items are returned.
- Home-- Promos
--- Promo 1 Details <-- 3rd level
---- About <-- 4th level
---- Terms and Conditions<-- 4th level
Hope this makes sense?
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.