VP-ASP :: Shopping Cart Software

Shopping Cart Software Solutions for anywhere in the World

US/Canada(Toll Free): +1 888 587 2278
Europe/UK: +44 (020) 7193 9408
Australia/New Zealand: +61 3 9016 4497

VP-ASP Shopping Cart Customer Forum

Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VPCart Forum
 Customization
 Free code piece: A more intuitive backwards nav...
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Dulrr
VP-ASP New User

57 Posts

Posted - July 21 2004 :  08:51:29  Show Profile  Visit Dulrr's Homepage  Reply with Quote
This was a fairly minor update, but it makes the backwards navigation from a category a little bit more intuitive, especially for carts like our own which have many layers of subcategories. This code will generate a list of links along the top of the screen, looking something like:

All Products > Broad Category > Refined Subcategory

And clicking on the link will take the shopper to that category instead of to the one above it. (The original code would go Broad Category > Refined Subcategory > This Category, and clicking on This Category takes you to Refined Subcategory)

Feel free to steal this snippet of code if desired - it replaces the sub "GenerateCategoryLinks" found in shopdisplaycategories.asp. I have also added it to shopdisplayproducts.asp, which requires a call to the function in the DisplayProducts sub.

The product and category pages needed slightly different logic to get them to work properly, so both variants will be provided.

shopdisplaycategories

'****************************************************************
'Generates links back to the product's categories at top of page
'Modified by ~D so that clicking on a category will go to that category
'instead of the one above it.
'****************************************************************
Sub GenerateCategoryLinks
dim highercatid, cats(10),catids(10), i
dim cathead, more, catsql, rs
dim id,name
'use the category we're in to determine which category we descended from
highercatid=getsess("Cat_id")
catsql="select * from categories where categoryid=" & highercategoryid
Set rs=dbc.execute(catsql)
highercatid=rs("highercategoryid")
Closerecordset rs
cathead=""
More=True
i=0

Do while more=True
'Loop to generate a list of categories until we hit the root - ie, where the highercatid=0
catsql="select * from categories where categoryid=" & highercatid
Set rs=dbc.execute(catsql)
If not rs.eof then
name=rs("catdescription")
id=rs("categoryid")
dim mylink
mylink="<a HREF=""shopdisplaycategories.asp?id=" & highercatid & "&cat=" & Server.URLEncode(name) & """>" & name & "</a>"
cats(i)=mylink
highercatid=rs("highercategoryid")
i=i+1
if highercatid=0 then
more=false
end if
else
more=false
end if
Closerecordset rs
loop
'When the root of the categories is hit add a link to the base level
mylink="<a HREF=""shopdisplaycategories.asp?id=" & highercatid & "&cat=" & Server.URLEncode(name) & """>" & "All Products" & "</a>"
cats(i)=mylink
i=i+1

For i = 0 to i-1
'Write out list of links
If cathead="" Then
cathead = cats(i)
else
cathead= cats(i) & subcatseparator & cathead
end if
next
response.write subcatheader & cathead & subcatheaderend
end sub




Edited by - Dulrr on July 21 2004 08:53:19

Dulrr
VP-ASP New User

57 Posts

Posted - July 21 2004 :  08:51:49  Show Profile  Visit Dulrr's Homepage  Reply with Quote
shopdisplayproducts

'****************************************************************
'Generates links back to the product's categories at top of page
'Modified by ~D so that clicking on a category will go to that category
'instead of the one above it. Modified for use in shopdisplayproducts.asp
'****************************************************************
Sub GenerateCategoryLinks
dim highercatid, cats(10),catids(10), i
dim cathead, more, catsql, rs
dim id,name
highercatid=getsess("Cat_id")
if highercatid<>"" then
'ignore this part if "Cat_id" is null to avoid errors when page is accessed through the shop search
'use the category we're in to determine which category we descended from
catsql="select * from categories where categoryid=" & highercatid
Set rs=dbc.execute(catsql)
highercatid=rs("highercategoryid")
cathead=""
More=True
i=0

Do while more=True
'Loop to generate a list of categories until we hit the root - ie, where the highercatid=0
catsql="select * from categories where categoryid=" & highercatid
Set rs=dbc.execute(catsql)
If not rs.eof then
name=rs("catdescription")
id=rs("categoryid")
dim mylink
mylink="<a HREF=""shopdisplaycategories.asp?id=" & highercatid & "&cat=" & Server.URLEncode(name) & """>" & name & "</a>"
cats(i)=mylink
highercatid=rs("highercategoryid") 'Move one up in the chain
i=i+1
if highercatid=0 then
'When the root of the categories is hit add a link to the base level
more=false
mylink="<a HREF=""shopdisplaycategories.asp?id=" & highercatid & "&cat=" & Server.URLEncode(name) & """>" & "All Products" & "</a>"
cats(i)=mylink
i=i+1
end if
else
more=false 'Handling for unexpected end of file
end if
Closerecordset rs
loop

For i = 0 to i-1
'Write out the links
If cathead="" Then
cathead = cats(i)
else
cathead= cats(i) & subcatseparator & cathead
end if
next
response.write subcatheader & cathead & subcatheaderend
end if
end sub


Hope this is useful!
~D

Edited by - Dulrr on July 21 2004 08:52:59
Go to Top of Page

robm
Starting Member

1 Posts

Posted - August 10 2004 :  11:48:13  Show Profile  Reply with Quote
Thanks for the code ~D

I would like to Mod it a little. Would like to add the name of the category you are on to the list of generated links as well. Of coure it would have no hyperlink.

An easy addition? Let me know what you think

-Rob
Go to Top of Page

Dulrr
VP-ASP New User

57 Posts

Posted - August 10 2004 :  14:13:59  Show Profile  Visit Dulrr's Homepage  Reply with Quote
Sure! I just e-mailed you the code that should do the trick - let me know if you still have trouble.

In summary, though, if anyone else wants to do the same:
1) add a new variable at the top to store the current category name. (eg: add the line "dim currentname" with the rest of the "dim ..." statements)

2) set the variable equal to the category name, rs("catdescription"), right after the following line (also near the top):
catsql="select * from categories where categoryid=" & highercatid
Set rs=dbc.execute(catsql)

3) modify the response.write line at the bottom of the sub so that we get an extra seperator and the name of the current category.

response.write subcatheader & cathead & subcatheaderend
becomes:
response.write subcatheader & cathead & subcatseparator & currentcatname & subcatheaderend

~D
Go to Top of Page

greatphoto
VP-ASP Super User

USA
304 Posts

Posted - August 10 2004 :  19:34:36  Show Profile  Reply with Quote
Hi Dullr-

Thanks for the code and discussion. This type of navigation is called "breadcrumbs." Here are several links to other discussion on this topic in the forum:

http://www.vpasp.com/virtprog/vpaspforum/topic.asp?TOPIC_ID=2620
http://www.vpasp.com/virtprog/vpaspforum/topic.asp?TOPIC_ID=547

Support wrote that they recognize the request for different breadcrumb operation and have completely rewritten it for the new version of the cart. Great news!

Nathan

Go to Top of Page

Dulrr
VP-ASP New User

57 Posts

Posted - August 11 2004 :  08:16:00  Show Profile  Visit Dulrr's Homepage  Reply with Quote
Ah! Hadn't realized that was the proper technical name so hadn't known this had already been addressed there!

Something new every day, right?

~D
Go to Top of Page

innocenti
Starting Member

USA
16 Posts

Posted - February 24 2005 :  17:15:39  Show Profile  Visit innocenti's Homepage  Reply with Quote
Hi - We have the same problem with our breadcrumbs.

http://www.lambretta.net/shop/shopdisplaycategories.asp?id=16&cat=Hardware

You can see by drilling into 'misc hardware' - we lose the breadcrumbs. Also, clicking on any of the crumbs does that 'jump back one level' thing, instead of going to the corresponding, and correct page.

Can you please tell me how to implement this code fully. I understand the replacement
"it replaces the sub "GenerateCategoryLinks" found in shopdisplaycategories.asp.", and have done so.

but am unclear where/how to do this:
"I have also added it to shopdisplayproducts.asp, which requires a call to the function in the DisplayProducts sub."

Obviously I am not an asp coder, but feel confident working on the files, as long as I have directions, as I work with css & html daily, and have succesfully altered other VP files already.

Thanks for your help!

Go to Top of Page

innocenti
Starting Member

USA
16 Posts

Posted - February 24 2005 :  19:25:20  Show Profile  Visit innocenti's Homepage  Reply with Quote
OK - got the first part to work (from my previous breadcrumb post), but am having some difficulty employing this... could you offer me a more detailed explanation?

THANKS!

quote:

Sure! I just e-mailed you the code that should do the trick - let me know if you still have trouble.

In summary, though, if anyone else wants to do the same:
1) add a new variable at the top to store the current category name. (eg: add the line "dim currentname" with the rest of the "dim ..." statements)

2) set the variable equal to the category name, rs("catdescription"), right after the following line (also near the top):
catsql="select * from categories where categoryid=" & highercatid
Set rs=dbc.execute(catsql)

3) modify the response.write line at the bottom of the sub so that we get an extra seperator and the name of the current category.

response.write subcatheader & cathead & subcatheaderend
becomes:
response.write subcatheader & cathead & subcatseparator & currentcatname & subcatheaderend

~D



Go to Top of Page

Justin
VP-ASP New User

87 Posts

Posted - February 24 2005 :  19:49:56  Show Profile  Visit Justin's Homepage  Reply with Quote
dulrr, your signature looks like a penis!

innocenti - what version of the cart are you using? Did you follow the links to the version that I worked on before (it was for v4.5) you might find that helps you understand the logic a little better.

Does anyone know exactly how the shopping cart works when a particular product is in more than one category? with my hacked version, it is possible to just between categories by selecting the product, and so the breadcrumbs don't let you go back.

Justin


Go to Top of Page

innocenti
Starting Member

USA
16 Posts

Posted - February 25 2005 :  15:14:31  Show Profile  Visit innocenti's Homepage  Reply with Quote
Hi Justin - I'm using 4.5, and could really use the link. It's just that last bit that's a bit confusing. Basically, everything is working until the final subcategory, where the breadcrumps disappear. Feel free to email me whatever you like. My life is freeaking glues to this thing!

*I*

quote:


innocenti - what version of the cart are you using? Did you follow the links to the version that I worked on before (it was for v4.5) you might find that helps you understand the logic a little better.


Justin






Go to Top of Page

Justin
VP-ASP New User

87 Posts

Posted - February 26 2005 :  19:04:15  Show Profile  Visit Justin's Homepage  Reply with Quote
Greatphoto mentioned it above:

http://www.vpasp.com/virtprog/vpaspforum/topic.asp?TOPIC_ID=547

Justin

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000