Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have a menu structure like this:
level1
level2
level3
I would like to create menu with only 2 levels from this structure. (print out level2 and level3 together).
To explain somthing like this.
<ul> @foreach (var page in home.Children.Where("Visible")) { <li><a href="@page.Url">@page.Name</a> @if (page.Children.Where("Visible").Count() > 0) { <ul> @foreach (var subpage in page.Children.Where("Visible")) { <li><a href="@subpage.Url">@subpage.Name</a></li> @foreach (var subsubpage in page.Children.Where("Visible")) { <li><a href="@subsubpage.Url">@subsubpage.Name</a></li> } } </ul> </li> } </ul>
Thanks in advance.
Hi Anders, I think you have only one issue in your snippet, try this:
<ul> @foreach (var page in home.Children.Where("Visible")) { <li><a href="@page.Url">@page.Name</a> @if (page.Children.Where("Visible").Count() > 0) { <ul> @foreach (var subpage in page.Children.Where("Visible")) { <li><a href="@subpage.Url">@subpage.Name</a></li> @foreach (var subsubpage in subpage.Children.Where("Visible")) { <li><a href="@subsubpage.Url">@subsubpage.Name</a></li> } } </ul> </li> } </ul>
Thanks. I am still getting error.
This will work. But it will not become propper html....
@{var home = Model.AncestorOrSelf(1);} <ul id="step2"> @foreach (var page in home.Children.Where("Visible")) { <li><a href="@page.Url">@page.Name</a> @if (page.Children.Where("Visible").Count() > 0) { <ul> @foreach (var subpage in page.Children.Where("Visible")) { <li><a href="@subpage.Url">@subpage.Name</a> @foreach (var subsubpage in subpage.Children.Where("Visible")) { <li><a href="@subsubpage.Url">@subsubpage.Name</a></li> } </li> } </ul> } </li> } </ul>
Just move your li?
@{var home = Model.AncestorOrSelf(1);} <ul id="step2"> @foreach (var page in home.Children.Where("Visible")) { <li><a href="@page.Url">@page.Name</a> @if (page.Children.Where("Visible").Count() > 0) { <ul> @foreach (var subpage in page.Children.Where("Visible")) { <li><a href="@subpage.Url">@subpage.Name</a></li> @foreach (var subsubpage in subpage.Children.Where("Visible")) { <li><a href="@subsubpage.Url">@subsubpage.Name</a></li> } } </ul> } </li> } </ul>
Thanks for quick reply.But.
Moving li gives error: Error loading MacroEngine script (file: )
Ah yes, you will need to remove the @ from the second loop,
@{var home = Model.AncestorOrSelf(1);} <ul id="step2"> @foreach (var page in home.Children.Where("Visible")) { <li><a href="@page.Url">@page.Name</a> @if (page.Children.Where("Visible").Count() > 0) { <ul> @foreach (var subpage in page.Children.Where("Visible")) { <li><a href="@subpage.Url">@subpage.Name</a></li> foreach (var subsubpage in subpage.Children.Where("Visible")) { <li><a href="@subsubpage.Url">@subsubpage.Name</a></li> } } </ul> } </li> } </ul>
Of course!!!! Thanks.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
List child and child-child together
I have a menu structure like this:
level1
level1
level2
level2
level3
level3
level1
I would like to create menu with only 2 levels from this structure. (print out level2 and level3 together).
To explain somthing like this.
Thanks in advance.
Hi Anders, I think you have only one issue in your snippet, try this:
Thanks. I am still getting error.
This will work. But it will not become propper html....
Just move your li?
Thanks for quick reply.But.
Moving li gives error: Error loading MacroEngine script (file: )
Ah yes, you will need to remove the @ from the second loop,
Of course!!!! Thanks.
is working on a reply...