Silly Sitemap Question

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
heinscott
Captain (CAPT)
Captain (CAPT)
Posts: 375
Joined: Thu May 01, 2008 12:37 pm

Silly Sitemap Question

Post by heinscott » Tue Sep 30, 2008 2:49 pm

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

User avatar
Shopping Cart Admin
AbleCommerce Admin
AbleCommerce Admin
Posts: 3055
Joined: Mon Dec 01, 2003 8:41 pm
Location: Vancouver, WA
Contact:

Re: Silly Sitemap Question

Post by Shopping Cart Admin » Tue Sep 30, 2008 3:52 pm

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.
Thanks for your support

Shopping Cart Guru
AbleCommerce.com
Follow us on Facebook

bptoll123
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 23
Joined: Sat Aug 23, 2008 8:19 am

Re: Silly Sitemap Question

Post by bptoll123 » Sun Jan 04, 2009 3:33 pm

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

kastnerd
Commodore (COMO)
Commodore (COMO)
Posts: 474
Joined: Wed Oct 22, 2008 9:17 am

Re: Silly Sitemap Question

Post by kastnerd » Wed Jan 07, 2009 8:34 am

I dont know about the automatic generator. But you can edit the map by hand with out hurting anything.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Silly Sitemap Question

Post by mazhar » Wed Jan 07, 2009 8:54 am

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)

bptoll123
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 23
Joined: Sat Aug 23, 2008 8:19 am

Re: Silly Sitemap Question

Post by bptoll123 » Sun Jan 11, 2009 11:55 am

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

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Silly Sitemap Question

Post by mazhar » Mon Jan 12, 2009 7:57 am

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.

Post Reply