Page 1 of 1

Silly Sitemap Question

Posted: Tue Sep 30, 2008 2:49 pm
by heinscott
Maybe this is a silly question, but, could anyone explain why the Sitemap generator would create a sitemap that includes hidden products and categories?
I'm assuming that there is no way around this problem, other than to create a sitemap some other way...?
Thanks for the help.

Scott

Re: Silly Sitemap Question

Posted: Tue Sep 30, 2008 3:52 pm
by Shopping Cart Admin
Hello Scott,

Guess not to many folks are using hidden products and feeds, we've confirmed this in the final build and will get it reported as a bug.

Re: Silly Sitemap Question

Posted: Sun Jan 04, 2009 3:33 pm
by bptoll123
Hi,
Has there been any fix provided for this issue?

IF not, could I manually go into my sitemap and just delete the lines with hidden products and categories? is there any checksum or something that would invalidate the file?

Thanks
Brian

Re: Silly Sitemap Question

Posted: Wed Jan 07, 2009 8:34 am
by kastnerd
I dont know about the automatic generator. But you can edit the map by hand with out hurting anything.

Re: Silly Sitemap Question

Posted: Wed Jan 07, 2009 8:54 am
by mazhar
You can try the following quick fix if you want to exclude the hidden categories, products and webpages from the site map.

Edit the App_Code/CommonSiteMapProvider.cs and locate the following line of code

Code: Select all

if (cat.Visibility != CatalogVisibility.Private)
and make it look like

Code: Select all

if (cat.Visibility != CatalogVisibility.Private && cat.Visibility != CatalogVisibility.Hidden)
Locate the following line of code

Code: Select all

if (prod.Visibility != CatalogVisibility.Private)
and make it look like

Code: Select all

if (prod.Visibility != CatalogVisibility.Private && prod.Visibility != CatalogVisibility.Hidden)
Locate the following line of code

Code: Select all

if (wp.Visibility != CatalogVisibility.Private)
and make it look like

Code: Select all

if (wp.Visibility != CatalogVisibility.Private &&  wp.Visibility != CatalogVisibility.Hidden)

Re: Silly Sitemap Question

Posted: Sun Jan 11, 2009 11:55 am
by bptoll123
This worked great!

One more thing... the sitemap here just captures the ablecommerce store. Is there any code i can add that will bring in the other sites I have? Able is my store, but i have lots of other static pages for educational purposes.

Thanks,
Brian

Re: Silly Sitemap Question

Posted: Mon Jan 12, 2009 7:57 am
by mazhar
This worked great!

One more thing... the sitemap here just captures the ablecommerce store. Is there any code i can add that will bring in the other sites I have? Able is my store, but i have lots of other static pages for educational purposes.

Thanks,
Brian
You can accomplish this in two ways.

1)- There is a method named PopulateCommonUrls in App_Code/CommonSiteMapProvider.cs file.

Code: Select all

private void PopulateCommonUrls(List<SiteMapUrl> siteMapItems, SiteMapOptions options) 
		{
			siteMapItems.Add(new SiteMapUrl(GetAbsoluteUrl("~/Default.aspx"), options.DefaultChangeFrequency, options.DefaultUrlPriority));
			siteMapItems.Add(new SiteMapUrl(GetAbsoluteUrl("~/ContactUs.aspx"), options.DefaultChangeFrequency, options.DefaultUrlPriority));
			siteMapItems.Add(new SiteMapUrl(GetAbsoluteUrl("~/AboutUs.aspx"), options.DefaultChangeFrequency, options.DefaultUrlPriority));
		}
and can update this method to generate the URL for your custom pages. For example if you have a page custompage.aspx and want it to include in site map then you have to change the method as below

Code: Select all

private void PopulateCommonUrls(List<SiteMapUrl> siteMapItems, SiteMapOptions options) 
		{
			siteMapItems.Add(new SiteMapUrl(GetAbsoluteUrl("~/Default.aspx"), options.DefaultChangeFrequency, options.DefaultUrlPriority));
			siteMapItems.Add(new SiteMapUrl(GetAbsoluteUrl("~/ContactUs.aspx"), options.DefaultChangeFrequency, options.DefaultUrlPriority));
			siteMapItems.Add(new SiteMapUrl(GetAbsoluteUrl("~/AboutUs.aspx"), options.DefaultChangeFrequency, options.DefaultUrlPriority));

            siteMapItems.Add(new SiteMapUrl(GetAbsoluteUrl("~/custompage.aspx"), options.DefaultChangeFrequency, options.DefaultUrlPriority));
		}
2)- If you want to auto generate the URL for all root pages then you can create a new function in the class just under the PopulateCommonUrls method and use it to generate the URLs for static pages in site map.

Code: Select all

 private void PopulateStaticUrls(List<SiteMapUrl> siteMapItems, SiteMapOptions options)
        {
            string url = "~/";
            string path = HttpContext.Current.Server.MapPath(url);
            String[] files = Directory.GetFiles(path,"*.aspx",SearchOption.TopDirectoryOnly);
            foreach (string file in files)
            {
                FileInfo fileInfo = new FileInfo(file);
                siteMapItems.Add(new SiteMapUrl(GetAbsoluteUrl(GetAbsoluteUrl("~/"+fileInfo.Name)), options.DefaultChangeFrequency, options.DefaultUrlPriority));        
            }
        }
after adding this method you will need to make some change in code. So locate the

Code: Select all

PopulateCommonUrls(siteMapItems, options);
and make it look like

Code: Select all

//PopulateCommonUrls(siteMapItems, options);
PopulateStaticUrls(siteMapItems, options);
Note that I have commented the call to PopulateCommonUrls because now our custom method will generate URLs for all root pages.

One more thing as adding all the root pages to the site map would not be a desired operation. So it would be better that you use some slandered name prefix for the custom pages. For example "Custom_MyPage.aspx". This means that all your custom pages names are prefixed now so you can update your custom function to generates the links for those pages as below

Code: Select all

private void PopulateStaticUrls(List<SiteMapUrl> siteMapItems, SiteMapOptions options)
        {
            string url = "~/";
            string path = HttpContext.Current.Server.MapPath(url);
            String[] files = Directory.GetFiles(path, "Custom_*.aspx", SearchOption.TopDirectoryOnly);
            foreach (string file in files)
            {
                FileInfo fileInfo = new FileInfo(file);
                siteMapItems.Add(new SiteMapUrl(GetAbsoluteUrl(GetAbsoluteUrl("~/"+fileInfo.Name)), options.DefaultChangeFrequency, options.DefaultUrlPriority));        
            }
        }
and finally update the call to this function by locating the

Code: Select all

PopulateCommonUrls(siteMapItems, options);
and make it look like

Code: Select all

PopulateCommonUrls(siteMapItems, options);
PopulateStaticUrls(siteMapItems, options);
Note now there is no need to comment the PopulateCommonUrls method call because now our custom method will only add custom pages to site map not all.