Copied to clipboard

Flag this post as spam?

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


  • Tom Madden 252 posts 454 karma points MVP 4x c-trib
    Mar 21, 2011 @ 22:26
    Tom Madden
    1

    Fix for Razor Sitemap html error - empty ul tags

    The Razor Site Map template in 4.7 produces empty ul tags which will show as errors in html validators. The simple fix to prevent thsi for people who are fussy about validating their html (like me), is to add a check for there being items before outputting the ul tag, so the relevant ul section becomes:

       var items = node.Children.Where("Visible").Where("Level <= maxLevelForSitemap", values);
         if (items.Count() > 0) { 
           <ul>
                    @foreach (var item in items) {
                        <li>
        <a href="@item.Url">@item.Name</a>
        @traverse(item)
                        </li>
                    }
           </ul>
        }

  • Eran 292 posts 436 karma points
    Apr 28, 2011 @ 03:15
    Eran
    0

    i also changed the first line to:

     var items = node.Children.Where("template!=0").Where("Visible").Where("Level <= maxLevelForSitemap", values);
    

    because usually you dont want to display items that dont have a template, for example images that "lives" only in gallery and dont have thier "own" page.

  • Sebastiaan Janssen 5045 posts 15477 karma points MVP admin hq
    Apr 28, 2011 @ 07:29
    Sebastiaan Janssen
    0

    This is great, make sure to contribute it back to Umbraco by creating an issue on codeplex about this. High five guys!

  • Eran 292 posts 436 karma points
    Apr 28, 2011 @ 12:13
    Eran
    0

    i open ticket in codeplex: http://umbraco.codeplex.com/workitem/30272

Please Sign in or register to post replies

Write your reply to:

Draft