Copied to clipboard

Flag this post as spam?

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


  • hetaurhet 245 posts 267 karma points
    Feb 25, 2012 @ 05:25
    hetaurhet
    0

    sitemap appears as XML

    hello...

    I have installed Cultiv Search Engine Sitemap (Razor edition). I renamed the template to Sitemap and razor to HTMLsitemal.cshtml. this template contains following code.

    <%@ Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
    <html>  
    <head>
    </head>  
     <body>  
    <umbraco:Macro runat="server" language="cshtml">
      @RenderPage("/macroScripts/HTMLSitemap.cshtml")
    </umbraco:Macro>
      </body>
    </html>  
    </asp:Content>

    and .cshtml have following code.

    <link rel="stylesheet" type="text/css" media="screen, print" href="/css/slickmap.css" />
    @ListChildNodes(Model.AncestorOrSelf(1))
    @helper ListChildNodes(dynamic startNode)
    {
        Response.ContentType = "text/xml";
        const int maxLevelForSiteMap = 100;
        
        
        foreach (var node in startNode.Children
            .Where("HasAccess")
            .Where("!IsProtected")
            .Where("umbracoNaviHide == false")
          )
        {     
            if(node.template > 0) {
                <url>
                    <loc>@GetUrlWithDomainPrefix(node.Url)</loc>
                    <lastmod>@(string.Format("{0:s}+00:00", node.UpdateDate))</lastmod>
                    @if (node.SearchEngineSitemapChangeFreq.ToString() != "")
                    {
                        <changefreq>@node.SearchEngineSitemapChangeFreq</changefreq>
                    }
                    @if (node.SearchEngineSitemapPriority.ToString() != "")
                    {
                        <priority>@node.SearchEngineSitemapPriority</priority>
                    }
                </url>
            }
                
            if (node.Level <= maxLevelForSiteMap && node.ChildrenAsList.Count > 0)
            {
                @ListChildNodes(node)
            }
        }
    }

    @functions {
        private static string GetUrlWithDomainPrefix(string url) {
            if (url.StartsWith("/"))
              url = url.Substring(1);
                                                                  
            var domainPrefix = string.Format("http://{0}/", HttpContext.Current.Request.ServerVariables["HTTP_HOST"]);
                                                                  
            if (url.StartsWith(domainPrefix))
                return url;
            else
                return domainPrefix + url;
        }
    }

    When I make page called sitamap with this template applied and run. It shows XML like content and in the top it shows... This XML file does not appear to have any style information associated with it. The document tree is shown below.

    So, what is the problem?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 25, 2012 @ 08:50
    Jan Skovgaard
    0

    Hi Heather

    I suppose you want to have a html based sitemap displayed, right? The package you installed is creating a sitemap specifically for search engines, which is why you get XML returned. XML sitemaps are used to submit to search engies so they can index the the pages on a site.

    If you need a html sitemap I belive you could benefit from using some of the predefined razor snippets or the sitemap xslt snippet in the developer section.

    Hope this helps.

    /Jan

  • hetaurhet 245 posts 267 karma points
    Feb 25, 2012 @ 09:56
    hetaurhet
    0

    yes, u r right.

Please Sign in or register to post replies

Write your reply to:

Draft