Itsoundsa little oddto me.I have justtried to createa sitemapfrom Razorsnippet(.cshtml) on aUmbraco6.1.6witha starterkitinstalled,and I have no problems getting sitemap to output the pages of the site.
The Razor snippet looks like this:
@inherits umbraco.MacroEngines.DynamicNodeContext
@{ @* Walk up the tree from the current page to get the root node *@ var rootNode = Model.AncestorOrself(1); }
@*Render the sitemap by passing the root node to the traverse helper*@ <div class="sitemap"> @traverse(@Model.AncestorOrSelf()) </div>
@*Helper method to travers through all descendants*@ @helper traverse(dynamic node){
@*If a MaxLevelForSitemap parameter is passed to the macro, otherwise default to 4 levels*@ var maxLevelForSitemap = String.IsNullOrEmpty(Parameter.MaxLevelForSitemap) ? 4 : int.Parse(Parameter.MaxLevelForSitemap);
@*Select visible children *@ var items = node.Children.Where("Visible").Where("Level <= " + maxLevelForSitemap);
@*If any items are returned, render a list *@ if (items.Any()) { <ul> @foreach (var item in items) { <li class="[email protected]"> <a href="@item.Url">@item.Name</a>
@*Run the traverse helper again *@ @traverse(item) </li> } </ul> } }
I just used the Razorsnippet as it comes out of the box. I have just tried to setup an empty Umbraco installation and create a template, and a document type. Then create a scripting file using the sitemap snippet. After that I added some content nodes.
Then I added the marco to the template, and it´s just outputs the pages I have in the content section. So it sounds a little bit odd that you can´t get it to work.
Sitemap (HTML)
I'm running Umbraco 6.16 running in Webform mode.
The included Razor snippet for creating a Razor HTML Sitemap does not work - there is no output.
Can someone PLEASE supply a working version?
Thanks!
Hi Dominic,
It sounds a little odd to me. I have just tried to create a sitemap from Razor snippet(.cshtml) on a Umbraco 6.1.6 with a starterkit installed, and I have no problems getting sitemap to output the pages of the site.
The Razor snippet looks like this:
/Dennis
Strange. I get no output at all, or errors!
I installed the empty site though, not the starter kit?
Did you set your root node to something different? Do I need to change that?
Hi Domnic,
I just used the Razor snippet as it comes out of the box. I have just tried to setup an empty Umbraco installation and create a template, and a document type. Then create a scripting file using the sitemap snippet. After that I added some content nodes.
Then I added the marco to the template, and it´s just outputs the pages I have in the content section. So it sounds a little bit odd that you can´t get it to work.
/Dennis
Maybe you can try the CultivSearchEngineSitemap package. make sure you install the razor version
Moran - that's for XML sitemaps isn't it? I need a HTML sitemap. The code example that ships with Umbraco simply doesn't work for me.
is working on a reply...