Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Sitemap.aspx recommended changeSitemap.aspx recommended change
Previous
 
Next
New Post
3/2/2010 3:26 PM
 

I'm on version 4.xxxxx and ran in to an issue with Sitemap.aspx - I have many portals on my instance (several hundred) and some of the users want to be able to override the default sitemap, since google want's the sitemap in the root, I modified the Sitemap.aspx code to just regurgitate the Sitemap.xml they upload into there own portals. This seems to be a simple fix for a lot of issues. Here's the code changes.

     Public Function BuildSiteMap(ByVal PortalID As Integer) As String

            Dim sb As New StringBuilder(1024)
            Dim URL As String

            Try
                ' Look for a Sitemap.xml file in the portal folder
                Dim inputFile As New DotNetNuke.Services.FileSystem.FileInfo
                inputFile.PortalId = PortalID
                inputFile.FolderId = PortalID
                inputFile.FileName = "Sitemap.xml"


                Dim inputStream As System.IO.Stream
                inputStream = FileSystemUtils.GetFileStream(inputFile)

                Dim doc As New System.Xml.XmlDocument
                doc.Load(inputStream)

                inputStream.Close()

                sb.Append(doc.InnerXml)

            Catch exc As Exception
                ' build header
                sb.Append("<?xml version=""1.0"" encoding=""UTF-8""?>" & ControlChars.CrLf)
                sb.Append("<urlset xmlns=""http://www.sitemaps.org/schemas/sitemap/0.9"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"">" & ControlChars.CrLf)

                ' add urls
                Dim intURLs As Integer = 0
                Dim objTabs As New TabController
                For Each objTab As TabInfo In objTabs.GetTabs(PortalID)
                    If objTab.IsDeleted = False AndAlso objTab.DisableLink = False AndAlso objTab.IsVisible AndAlso objTab.TabType = TabType.Normal AndAlso ((Null.IsNull(objTab.StartDate) = True OrElse objTab.StartDate < Now) AndAlso (Null.IsNull(objTab.EndDate) = True OrElse objTab.EndDate > Now)) Then
                        ' the crawler is an anonymous user therefore the site map will only contain publicly accessible pages
                        If PortalSecurity.IsInRoles(objTab.AuthorizedRoles) Then
                            If intURLs < SITEMAP_MAXURLS Then
                                intURLs += 1
                                URL = objTab.FullUrl
                                If URL.ToLower.IndexOf(Request.Url.Host.ToLower) = -1 Then
                                    URL = AddHTTP(Request.Url.Host) & URL
                                End If
                                sb.Append(BuildURL(URL, 2))
                            End If
                        End If
                    End If
                Next

                sb.Append("</urlset>")
            End Try
            Return sb.ToString

        End Function

 

Now ONE issue is if the Sitemap.xml is in the portal folder and the crawler sees it, so if that's an issue you could rename the sitemap.xml to something like sitemap.txt or somesuch, and change the code accordingly.

Seems pretty straightfoward.

 

 

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Sitemap.aspx recommended changeSitemap.aspx recommended change


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out