I need it to look like this. Where the "h2" is the name of the Parent page and "li" is the children pages and then the "div class mb" is used around every group of links.
Is it possible and what do I need to change in the code? Does it have something to do with the location of "@Traverse(item)"? I am thinking maybe use "In group of".
I have take a look at your code for the sitemap, and with this code you should get the HTML outputted, as you described in your post.
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@* Render the sitemap by passing the root node to the traverse helper *@
@Traverse(CurrentPage.AncestorOrSelf(1))
@* Helper method to travers through all descendants *@ @helper Traverse(dynamic node) { @* Update the level to reflect how deep you want the sitemap to go *@ var maxLevelForSitemap = 4;
@* Select visible children *@ var items = node.Children.Where("Visible").Where("Level <= " + maxLevelForSitemap);
@* If any items are returned, render a list *@ if (items.Any()) {
foreach(var item in items.Where("Visible").Where("Level == 2")){ <div class="mb"> <h2> @item.Name </h2> <ul> @foreach(var sitemapItem in item.Children){
Sitemap with special layout
Hi,
I need a sitemap with a special layout. Right now I have no problems showing the sitemap, but the layout and code is wrong. The code looks like this:
And the HTLM output looks like this:
I need it to look like this. Where the "h2" is the name of the Parent page and "li" is the children pages and then the "div class mb" is used around every group of links.
Is it possible and what do I need to change in the code? Does it have something to do with the location of "@Traverse(item)"? I am thinking maybe use "In group of".
Any suggestions?
// René
Hi Rene,
Can you try to use few for each nested each other ?
Hi Alex,
I have tried to search for an example on "few foreach" but I only find php code.
Can you post an code example?
Thanks!
// René
Hi René
I have take a look at your code for the sitemap, and with this code you should get the HTML outputted, as you described in your post.
Maybe you need to do some modification depending on how your content structure looks like.
Hope this helps,
/Dennis
Hi Dennis,
It works perfectly. Thanks!
// René
is working on a reply...