Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dominic Kelly 114 posts 133 karma points
    Jan 09, 2014 @ 16:33
    Dominic Kelly
    0

    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!

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jan 09, 2014 @ 17:30
    Dennis Aaen
    0

    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:

    @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>
        }
    }

    /Dennis

  • Dominic Kelly 114 posts 133 karma points
    Jan 09, 2014 @ 17:34
    Dominic Kelly
    0

    Strange. I get no output at all, or errors!

    I installed the empty site though, not the starter kit?

  • Dominic Kelly 114 posts 133 karma points
    Jan 09, 2014 @ 17:36
    Dominic Kelly
    0

    Did you set your root node to something different? Do I need to change that?

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jan 09, 2014 @ 17:55
    Dennis Aaen
    0

    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

  • Moran 285 posts 934 karma points
    Jan 12, 2014 @ 19:50
    Moran
    0

    Maybe you can try the CultivSearchEngineSitemap package. make sure you install the razor version

  • Dominic Kelly 114 posts 133 karma points
    Jan 13, 2014 @ 11:25
    Dominic Kelly
    0

    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.

Please Sign in or register to post replies

Write your reply to:

Draft