Site Map Page for Users on Storefront

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
ajasko
Lieutenant (LT)
Lieutenant (LT)
Posts: 53
Joined: Sun Sep 23, 2007 8:04 pm
Contact:

Site Map Page for Users on Storefront

Post by ajasko » Wed Sep 17, 2008 11:34 am

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.

User avatar
heinscott
Captain (CAPT)
Captain (CAPT)
Posts: 375
Joined: Thu May 01, 2008 12:37 pm

Re: Site Map Page for Users on Storefront

Post by heinscott » Wed Sep 17, 2008 11:54 am

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

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>
and the Sitemap.ascx.cs

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, "&nbsp;",20);
        CategoryLinks.Text += myCategoryLinks + "</td></tr></table>";
    }

    protected static void RecursiveLoadParents(int CatId, string delimeter, int fontsize)
    {
        fontsize = fontsize - 2;
        if (CatId > 0)
            delimeter = "&nbsp;&nbsp;&nbsp;&nbsp;" + 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);
        }
    }
}
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

User avatar
ajasko
Lieutenant (LT)
Lieutenant (LT)
Posts: 53
Joined: Sun Sep 23, 2007 8:04 pm
Contact:

Re: Site Map Page for Users on Storefront

Post by ajasko » Wed Sep 17, 2008 3:37 pm

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).

User avatar
Tomgard
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 108
Joined: Sun Jul 20, 2008 1:00 pm

Re: Site Map Page for Users on Storefront

Post by Tomgard » Wed Sep 17, 2008 6:36 pm

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?
Bryan Bundgaard
AC7 User http://www.SchoolSupplyStore.com

User avatar
heinscott
Captain (CAPT)
Captain (CAPT)
Posts: 375
Joined: Thu May 01, 2008 12:37 pm

Re: Site Map Page for Users on Storefront

Post by heinscott » Thu Sep 18, 2008 7:25 am

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).
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 line

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

User avatar
ajasko
Lieutenant (LT)
Lieutenant (LT)
Posts: 53
Joined: Sun Sep 23, 2007 8:04 pm
Contact:

Re: Site Map Page for Users on Storefront

Post by ajasko » Thu Sep 18, 2008 7:22 pm

It works!

combra
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 98
Joined: Thu Jul 31, 2008 7:09 pm

Re: Site Map Page for Users on Storefront

Post by combra » Thu Sep 18, 2008 8:08 pm

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

User avatar
Tomgard
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 108
Joined: Sun Jul 20, 2008 1:00 pm

Re: Site Map Page for Users on Storefront

Post by Tomgard » Thu Sep 18, 2008 8:19 pm

I dont think it is supposed to show the products. Only Category/Sub/Sub
Bryan Bundgaard
AC7 User http://www.SchoolSupplyStore.com

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

Re: Site Map Page for Users on Storefront

Post by mazhar » Thu Sep 18, 2008 10:43 pm

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 = "&nbsp;&nbsp;&nbsp;&nbsp;" + 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);
        }
    }

User avatar
Tomgard
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 108
Joined: Sun Jul 20, 2008 1:00 pm

Re: Site Map Page for Users on Storefront

Post by Tomgard » Mon Nov 10, 2008 2:46 pm

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

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

Re: Site Map Page for Users on Storefront

Post by mazhar » Tue Nov 11, 2008 7:14 am

You can try by putting some level support. For example change the function

Code: Select all

RecursiveLoadParents(int CatId, string delimeter, int fontsize)
to

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 = "&nbsp;&nbsp;&nbsp;&nbsp;" + 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);
        }
    }
and update the following statement in Page_Load

Code: Select all

RecursiveLoadParents(0, "&nbsp;", 20);
to

Code: Select all

RecursiveLoadParents(0, "&nbsp;", 20,5);
Where the last five the depth level

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

Re: Site Map Page for Users on Storefront

Post by kastnerd » Tue Nov 11, 2008 8:11 am

I would have 2 site maps. One for the users, and one using the official site map format for search engines.

User avatar
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

Post by jmestep » Tue Nov 11, 2008 9:33 am

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


User avatar
Tomgard
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 108
Joined: Sun Jul 20, 2008 1:00 pm

Re: Site Map Page for Users on Storefront

Post by Tomgard » Wed Nov 12, 2008 3:33 pm

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

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

Re: Site Map Page for Users on Storefront

Post by mazhar » Thu Nov 13, 2008 3:59 am

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.
Here is the site map control i modified for levels support.

Post Reply