The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Tracking category nav in Classic ASP without using Querystring

Okay I'm hoping someone can help me with this.  I'm using Classic ASP (yeah.... but we already have a Classic ASP site) and trying to do a category navigation structure.  There's always at least 2 categories, and can be as many as six.

What I want is for when the user clicks a category, the page is refreshed and shows a list of subcategories along with a count of all the products that are underneath that category.  A breadcrumb tracker should also be updated that shows the navigation so far (e.g. Office Supplies -> Binders -> Three Ring Binders)

The issue is that I cannot use the querystring parameter for this - I've written some custom functions that prettify the URLs since there's no way to do real URL rewriting in Classic ASP.  My function makes for pretty URLs like "1-office-supplies" instead of "category=1", and I have a function to parse the ID out of these pretty URLs.

I need to keep track of what level of navigation the user is at, so I know what category level to look for in the SQL query.  The fields are named like this:

... and so on

So the SQL query to find all subcategories needs to be dynamically generated - the field names are equal to the current category (e.g. category_lvl_2) while if the current category is greater than 1 there's a WHERE clause added that searches based on the ID of the parent (e.g. category_lvl_1_id) - but right now it only works for the first two levels and I can't figure out how to be able to keep track of the current level (and it should always be 1 when first hitting the page).  I'm so used to C#/Java where I can use static variables to keep track, but there aren't any such thing in VBScript.

Can anyone provide some insight or assistance to this?  It's been a long time since I've dabbled in Classic ASP.
Now I remember why I hate Classic ASP
Friday, December 05, 2008
As much as I hate classic ASP myself, I have to laugh at it for you blaming it for this issue.

You seem to have forgot HTTP 101, nothing classic ASP specific ... fail, pal.

That said, POST to your verbose URLs instead of GET. Pass values via one or more form variables. Quit relying on high-level abstractions, and understand the lower-level mechanisms you're dealing with.
Andrew Badera Send private email
Friday, December 05, 2008
I suppose I do "fail", but wouldn't using POST for clicking a hyperlink break a cardinal rule of web development?
Now I remember why I hate Classic ASP
Friday, December 05, 2008
1. You're already breaking paradigms by rewriting URLs in a fashion that means losing querystring capability.
2. The only risk of setting up POSTs via link clicks is that scripting is disabled. That's a risk you run. You don't have a lot of options here. Are the verbose URLs really worth it?
Andrew Badera Send private email
Saturday, December 06, 2008
"Are the verbose URLs really worth it?"

In my opinion no, but management wants friendly URLs for SEO stuff instead of the usual page.asp?param=value&param2=otherValue
Now I remember why I hate Classic ASP
Saturday, December 06, 2008
write an ISAPI extension if you want to rewrite (process) your own URL format.
Sunday, December 07, 2008
Why can't you use Query string parameters?

Some random options
1) use a cookie
2) (as above) use post, not get + hidden form fields
3) use frames. You'd really just be using a querystring, but the top level frame would still say
4) ghastly hack - change one of the requestor fields.

1+2 - add an onclick event to your link and either set cookie or do form.submit there. Return false.
Justin Send private email
Sunday, December 07, 2008
I can't use Querystring because it will muck up the "prettier" URLs I plan to use:

Basically if you click on the "Office Supplies" link, the URL would be something like:

products.asp?category=11-office-supplies instead of products.asp?category=11

To help with SEO.  Putting something like categoryLevel=1&category=11-office-supplies isn't as elegant I think, but I guess if it's just for that it might be the only option.

My boss wants pretty URLs, but Classic ASP doesn't support this naturally and I don't know about using an ISAPI filter because we have a few legacy sites and they might break if I install any kind of filter (I admit I've never done anything with ISAPI filters)
Now I remember why I hate Classic ASP
Sunday, December 07, 2008
It sounds to me like your problem is really with your DB schema, not Classic ASP. If you find yourself having to construct dynamic SQL where you refer to different columns depending on what category you're in, that's a good sign that your schema is not well suited to the task at hand.

If you post minimal DDL for your tables, I might be able to suggest an alternative.
Sunday, December 07, 2008
That's how the data is provided by our vendor.  The table structure is something like the following:

create table category_hierarchy
  id int not null,
  sku varchar(50) not null unique,
  category_1_id int not null,
  category_1 varchar(200) not null,
  category_2_id int not null,
  category_2 varchar(200) not null,
  category_3_id int not null default(0),
  category_3 varchar(200) null
  /* repeat for 4, 5, 6 */

the structure as provided can have at the least 2 categories (e.g. Furniture -> Desks and Accessories) and as many as 6 categories depending on the product.  We want to display a list of relevant products for categories 3-6 (filtering each time to get a list of associated products with that category) as well as display a side bar that counts and displays the products in the next sub-category, beginning with category 2. i.e.:

select sku, <category_X+1_id> as category_id, <category_X+1> as category_name, count(sku) as products_count from category_hierarchy where category_X_id = ? group by sku, category_x+1_id, category_x+1

Assuming:  Office Supplies (Cat1) -> File Folders (Cat2):

Pocket File Folders (15)
Index Tabs (25)
< and so on >

enabling the user to filter down as needed based on common attributes.  There's a related table that has brand information and we want to group by and display the count for that as well as the user gets down into the hierarchy.  My boss wants to allow for ease of navigation and drilldown based on various attributes.

The data as provided has its own set of keys that are unrelated to anything else, and actually splits the SKU into two columns (prefix and stock number) which I combine in my own code.  Most tables have compound keys based on the Prefix/Stock combination.

I can provide more detailed schema definition if needed.
Now I remember why I hate Classic ASP
Sunday, December 07, 2008
The other issue is that this data is provided in MS Access format, which I import into SQL Server, so the keys and constraints are not carried over.  I can re-create them once I come up with a way to do what I need to.
Now I remember why I hate Classic ASP
Sunday, December 07, 2008
URLs already have a perfectly good way to represent paths into a graph: hierarchy.  Structure your URLs:

and you will be able to inspect them to see (a) what you're looking at (a category) and (b) what the path to it is, for things like breadcrumbs. As a nice side effect, they're nearly automatically SEO friendly.

Most web frameworks have some way to implement this, usually referred to as "Path info" or similar. In this example the handler would probably be attached to either the / path or the /category/ path and would parse the rest of the path itself to decide what to display.

If your framework won't let you do this, insert something in front to do it: using Apache mod_rewrite you could expose a URL like the one above to the world while internally using

pretty easily; then you can walk down the list of values for the "cat" query parameter to generate your position and path in the hierarchy.

Finally, read this:


Tuesday, December 09, 2008

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz