Site Map Page for Users on Storefront
Site Map Page for Users on Storefront
I would like to have a viewable sitemap on my storefront that has links to all the major pages on my site (main pages, categories, subcategories). This is useful for users to navigate, and search engines like it as well, as it boosts the internal linking scheme of a site. The preferable name would be "sitemap.aspx." The sitemap mxl generator is nice and great for search engine submission, but a viewable sitemap webpage is equally useful, if not more so.
Andrew Jasko
http://www.telephonesystemsforbusiness.com
http://www.telephonesystemsforbusiness.com
Re: Site Map Page for Users on Storefront
Here's a CONLIB I made to recursively build all Categories, with Children underneath. I have each level getting smaller, so, if they are nested too far, you might have some readability issues. This would be something to start from...
Sitemap.ascx
and the Sitemap.ascx.cs
The "recursiveCount >=1500" is what determines the height of the stacks. You can play around with that number.
This will only build a sitemap of links for the category pages. If you need to add static pages, etc, you'll have to do that part manually.
Hope this helps.
Scott
Sitemap.ascx
Code: Select all
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SiteMap.ascx.cs" Inherits="ConLib_SiteMap" %>
<%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %>
<ajax:UpdatePanel ID="DescriptionAjax" runat="server">
<ContentTemplate>
<div class="content">
<table width="100%" cellspacing=0 cellpadding=0>
<tr>
<td>
<span class="CategoryHeader">SiteMap</span>
</td>
</tr>
<tr>
<td>
<br />
</td>
</tr>
<tr>
<td>
<asp:Literal ID="CategoryLinks" runat="server"></asp:Literal>
</td>
</tr>
</table>
</div>
</ContentTemplate>
</ajax:UpdatePanel>
Code: Select all
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CommerceBuilder.Common;
using CommerceBuilder.Utility;
using CommerceBuilder.Products;
using CommerceBuilder.Catalog;
public partial class ConLib_SiteMap : System.Web.UI.UserControl
{
static String myCategoryLinks = "";
static int recursiveCount = 0;
protected void Page_Init(object sender, EventArgs e)
{
}
protected void Page_Load(object sender, EventArgs e)
{
recursiveCount = 0;
myCategoryLinks = "";
CategoryLinks.Text = "<table width='100%' cellpadding=5><tr><td style='vertical-align:top'>";
RecursiveLoadParents(0, " ",20);
CategoryLinks.Text += myCategoryLinks + "</td></tr></table>";
}
protected static void RecursiveLoadParents(int CatId, string delimeter, int fontsize)
{
fontsize = fontsize - 2;
if (CatId > 0)
delimeter = " " + delimeter;
CategoryCollection cc = CategoryDataSource.LoadForParent(CatId, true);
foreach (Category c in cc)
{
recursiveCount = recursiveCount + fontsize;
if (recursiveCount >= 1500)
{
myCategoryLinks += "</td><td style='vertical-align:top'>";
recursiveCount = 0;
}
myCategoryLinks += delimeter + "<span style='font-size:" + fontsize + "px'><a href='" + c.NavigateUrl.Substring(2) + "'>" + c.Name + "</a></span><br>";
RecursiveLoadParents(c.CategoryId, delimeter, fontsize);
}
}
}
This will only build a sitemap of links for the category pages. If you need to add static pages, etc, you'll have to do that part manually.
Hope this helps.
Scott
Re: Site Map Page for Users on Storefront
Thanks for this! Sorry for my lack of competency, but how would I post this on a page in the storefront? (say on sitemap.aspx for example).
Andrew Jasko
http://www.telephonesystemsforbusiness.com
http://www.telephonesystemsforbusiness.com
Re: Site Map Page for Users on Storefront
Just finished my MANUAL creation of a site map and you post this!
I'd rather use this - thank you for posting. I was told that a good SEO practice is to keep the links on a page to under 100. I am WELL over that number with my site map. Do you think it is possible to add pager controls to such a page?

I'd rather use this - thank you for posting. I was told that a good SEO practice is to keep the links on a page to under 100. I am WELL over that number with my site map. Do you think it is possible to add pager controls to such a page?
Bryan Bundgaard
AC7 User http://www.SchoolSupplyStore.com
AC7 User http://www.SchoolSupplyStore.com
Re: Site Map Page for Users on Storefront
Make your file (probably the best way would be to copy Webpage.aspx), and rename it to SiteMap.aspx (don't accidently overwrite the sitemap.aspx in the root directory!). Next, when you navigate to that page (when logged in), edit the page, and go to the content section. Hit the edit button, then choose "Manage Scriptlets". On the right side of the screen, choose "Content" from the dropdown, then type a name (Probably SiteMap). Click Add. Then only part that is necessary to edit in this next screen is the content section. Add the lineThanks for this! Sorry for my lack of competency, but how would I post this on a page in the storefront? (say on sitemap.aspx for example).
Code: Select all
[[Conlib:Custom/Sitemap]]
The other two files I send, just make sure you put them in the Conlib/Custom directory.
That should do it for you.
As for paging controls...
You could definitely do that, although, my code is not setup that way. Probably if you, instead of adding links to the asp:Literal, were to add the data to some type of object, you could then populate a grid with the information, and use paging controls that way. I didn't want to go to all that hassle...

Hope this helps.
Scott
Re: Site Map Page for Users on Storefront
It works!
Andrew Jasko
http://www.telephonesystemsforbusiness.com
http://www.telephonesystemsforbusiness.com
Re: Site Map Page for Users on Storefront
I got part of this to work, as it shows the main categories, but none of the child categories (basically the products). What could I have done wrong?
AC 7.0.7 build 14600
Re: Site Map Page for Users on Storefront
I dont think it is supposed to show the products. Only Category/Sub/Sub
Bryan Bundgaard
AC7 User http://www.SchoolSupplyStore.com
AC7 User http://www.SchoolSupplyStore.com
Re: Site Map Page for Users on Storefront
If you want to show products as well then you must load the catalog nodes. For example in this case the RecursiveLoadParents method should be something like below
Code: Select all
protected static void RecursiveLoadParents(int CatId, string delimeter, int fontsize)
{
fontsize = fontsize - 2;
if (CatId > 0)
delimeter = " " + delimeter;
CatalogNodeCollection cc = CatalogNodeDataSource.LoadForCategory(CatId, true);
foreach (CatalogNode c in cc)
{
recursiveCount = recursiveCount + fontsize;
if (recursiveCount >= 1500)
{
myCategoryLinks += "</td><td style='vertical-align:top'>";
recursiveCount = 0;
}
myCategoryLinks += delimeter + "<span style='font-size:" + fontsize + "px'><a href='" + c.NavigateUrl.Substring(2) + "'>" + c.Name + "</a></span><br>";
RecursiveLoadParents(c.CatalogNodeId, delimeter, fontsize);
}
}
Re: Site Map Page for Users on Storefront
What if I wanted to show JUST top level categories in my site map? This code exposes 1200+ links in my site map and my SEO does not like that!
Bryan Bundgaard
AC7 User http://www.SchoolSupplyStore.com
AC7 User http://www.SchoolSupplyStore.com
Re: Site Map Page for Users on Storefront
You can try by putting some level support. For example change the function
to
and update the following statement in Page_Load
to
Where the last five the depth level
Code: Select all
RecursiveLoadParents(int CatId, string delimeter, int fontsize)
Code: Select all
protected static void RecursiveLoadParents(int CatId, string delimeter, int fontsize,int level)
{
if (level <= 0)
return;
level--;
fontsize = fontsize - 2;
if (CatId > 0)
delimeter = " " + delimeter;
CategoryCollection cc = CategoryDataSource.LoadForParent(CatId, true);
foreach (Category c in cc)
{
recursiveCount = recursiveCount + fontsize;
if (recursiveCount >= 1500)
{
myCategoryLinks += "</td><td style='vertical-align:top'>";
recursiveCount = 0;
}
myCategoryLinks += delimeter + "<span style='font-size:" + fontsize + "px'><a href='" + c.NavigateUrl.Substring(2) + "'>" + c.Name + "</a></span><br>";
RecursiveLoadParents(c.CategoryId, delimeter, fontsize,level);
}
}
Code: Select all
RecursiveLoadParents(0, " ", 20);
Code: Select all
RecursiveLoadParents(0, " ", 20,5);
Re: Site Map Page for Users on Storefront
I would have 2 site maps. One for the users, and one using the official site map format for search engines.
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: Site Map Page for Users on Storefront
You can generate a sitemap.xml for search engines under the Website-XML Sitemap button in the admin.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Re: Site Map Page for Users on Storefront
A useful topic from WIKI
http://wiki.ablecommerce.com/index.php/ ... th_Sitemap
http://wiki.ablecommerce.com/index.php/ ... th_Sitemap
Re: Site Map Page for Users on Storefront
I was not able to use the code provided by Mazhar to create a site map for just top level categories. I tried several different changes to make it work. Beyond my capabilities at this point.
Bryan Bundgaard
AC7 User http://www.SchoolSupplyStore.com
AC7 User http://www.SchoolSupplyStore.com
Re: Site Map Page for Users on Storefront
Here is the site map control i modified for levels support.I was not able to use the code provided by Mazhar to create a site map for just top level categories. I tried several different changes to make it work. Beyond my capabilities at this point.