Author |
Topic |
|
Scott@Tricotti
Starting Member
USA
8 Posts |
Posted - July 11 2002 : 10:56:08
|
Breadcrumbs did not work properly.. clicking on a breadcrumb always took you to one page before the correct page. Plus a final category page did not show the breadcrumbs..
I've pulled the breadcrumb code into its own file and blackboxed it so there are no sideaffects or dependencies other than the parameters. There is no longer any limit to the number of breadcrumbs.. although 10 was sufficient. The breadcrumb limit was not tested for and would have crashed if exceeded. The code is much smaller, tighter, and faster. Here it is... save this code as breadcrumbs.asp and include it in any file where you want to use it... I've linked it into shopdisplaycategories.asp and shopdisplayproducts.asp.
You can see the breadcrumbs in action at http://www.cwxonline.com
<% '------------------------------------------------------------------------------ ' SUB GenerateBreadCrumbs ' This general purpose function is used to create a sequential list of links ' for display on the screen. ' Scott Saunders - Tricotti.com - 11 July 2002 ' Parameters ' dbc: database connection ' startcatid: category id of the trail end of the breadcrumb ' separator: typically -> or --> ' Return value ' text string of links to pages and their names ' Crumb 1 -> Crumb 2 -> Crumb 3 -> Start Crumb '------------------------------------------------------------------------------ function GenerateBreadCrumbs(dbc,startcatid,separator) '' ----- DECLARE LOCAL VARIABLES ----- dim cathead ' final output string dim rs ' record set object for holding contents of the record dim catname ' name of the current category dim catid ' which category record is currently being processed dim i ' general purpose iterator dim mylink ' the link that is generated for the category '' ----- INITIALIZE LOCAL VARIABLES ----- cathead="" catid = startcatid '' ----- GET ALL CATEGORIES AND BUILD THE RETURN STRING ----- Do while catid <> 0 Set rs=dbc.execute("select * from categories where categoryid=" & catid) If not rs.eof Then catname=rs("catdescription") mylink="<a HREF=""shopdisplaycategories.asp?id=" & catid & "&cat=" & Server.URLEncode(catname) & """>" & catname & "</a>" If catid = startcatid Then cathead = mylink Else cathead = mylink & separator & cathead End If catid = rs("highercategoryid") Else Closerecordset rs Exit Do End If Closerecordset rs Loop
GenerateBreadCrumbs = cathead end function %>
Scott Saunders www.tricotti.com [email protected] [540] 822 9773 Better Technology for Better Business Intranets, Extranets, and wireless technology ======================================================
Edited by - Scott@Tricotti on July 18 2002 19:50:59 |
|
Justin
VP-CART New User
87 Posts |
Posted - April 15 2004 : 07:56:53
|
Nice code, Scott.
I've hacked it (badly) a little to fit my page. I thought it might be of help to some people. The main changes I wanted was:
* a "Home" breadcrumb at the beginning of each chain * the last crumb to not be a link. ie we are already *on* that page. Why would we want to follow a link to it??? * The breadcrumbs to work on the extended product description page (this is the biggest hack) * (this might only be specific to my particular cart setup) I only wanted it to call shopdisplaycategories if the user clicks on the root category in the chain (ie the one after 'home'). The subcategories with the products in are to call shopdisplayproducts. I've got a feeling I'm going to need to hack this a bit more. But it's late now and I'm tired. If someone else can see what I *should* be doing please feel free to make a suggestion.
known bugs:
* point 4 above. It won't work unless your cart is setup same as mine I think. * hardcoded default.asp * it's made for people who allow a product to be in multiple categories. * following on from this, if the product *is* in multiple categories the chain of breadcrumbs will not necessarily show the path the user took to get there. It will show the first 'path' entered in the database (ie the first category you put the product in). What this does is creates a strange (good?) side effect however, whereby products that are clicked on in a search will have a full crumb trail (although it might not be the only one possible).
ANyway, it's as is. Scott's original work that I just modified.
Justin
<% '------------------------------------------------------------------------------ ' SUB GenerateBreadCrumbs ' This general purpose function is used to create a sequential list of links ' for display on the screen. ' Scott Saunders - Tricotti.com - 11 July 2002 ' Parameters ' dbc: database connection ' startcatid: category id of the trail end of the breadcrumb ' separator: typically -> or --> ' Return value ' text string of links to pages and their names ' Crumb 1 -> Crumb 2 -> Crumb 3 -> Start Crumb
' changes by Justin ' If product=true then generate a dummy final ' ' Changes: * can be included on extended product pages (pass the product id, specify product=true) ' * don't make the last crumb a link ' * include a "home" link to the homepage (always on) ' * calls shopdisplayproducts instead of shopdisplaycategories if it's not a root category
'------------------------------------------------------------------------------ function GenerateBreadCrumbs(dbc,startcatid,separator,product) '' ----- DECLARE LOCAL VARIABLES ----- dim cathead ' final output string dim rs ' record set object for holding contents of the record dim catname ' name of the current category dim catid ' which category record is currently being processed dim i ' general purpose iterator dim mylink ' the link that is generated for the category
'' ----- INITIALIZE LOCAL VARIABLES -----
if product=true then ' if we are on an extended description page then we: ' (a) don't want the product name to be a link, and ' (b) need to specify which category the product is from set rs=dbc.execute("SELECT products.cname, categories.categoryid FROM categories INNER JOIN (products INNER JOIN prodcategories ON products.catalogid = prodcategories.intcatalogid) ON categories.categoryid = prodcategories.intcategoryid WHERE (((products.catalogid)=" & startcatid & "))") cathead=rs("cname") catid=rs("categoryid") else cathead="" catid = startcatid End if
'' ----- GET ALL CATEGORIES AND BUILD THE RETURN STRING ----- Do while catid <> 0 Set rs=dbc.execute("select * from categories where categoryid=" & catid) If not rs.eof Then catname=rs("catdescription") if catid = startcatid then ' case where it's a product name mylink=catname else if rs("highercategoryid")=0 then ' case where it's a root category mylink="<a HREF=""shopdisplaycategories.asp?id=" & catid & "&cat=" & Server.URLEncode(catname) & """>" & catname & "</a>" else ' case where it's a subcaategory with products in it mylink="<a HREF=""shopdisplayproducts.asp?id=" & catid & "&cat=" & Server.URLEncode(catname) & """>" & catname & "</a>" end if end if
If catid = startcatid Then cathead = mylink
Else cathead = mylink & separator & cathead End If catid = rs("highercategoryid") Else Closerecordset rs Exit Do End If Closerecordset rs Loop
GenerateBreadCrumbs = "<a href='default.asp'>Home</a> > " & cathead ' I shouldn't hard-code default.asp but it's late... end function %>
|
|
|
Cam
VP-CART Super User
Australia
361 Posts |
|
greatphoto
VP-CART Super User
USA
304 Posts |
Posted - April 16 2004 : 19:32:20
|
Hi Scott and Justin-
Great work! I'm excited to see others are having and solving the same challenges I've been dealing with over the last few weekends.
I also noticed that the Breadcrumbs (also called "Category Trail") didn't work as I expected. I think the more standard convention is to display them as Scott described. It turns out that according to support that it was specifically designed to work the way it does. Support pointed me to the lines of code, and I modified it to work similar to the way Scott did.
I also agree that it should show up on all the pages so the user gets accustomed to expecting it and can rely on it to be there. If it suddenly isn't available on a certain page, they'll feel a bit lost and abandoned. Its like they had a guide who suddenly ran off on them when they needed it most.
I also agree with Justin's approach of having the site home show up at the beginning of the crumbs, and for the last entry not to be a link. I made the same changes just last weekend also not realizing you were working on it.
I also attempted to make it show up in the extended products page, but ran into the same problem that Justin mentioned. The extended products page is referenced by product id ONLY without including the category that was used to get there. I think this is due to the fact that a product can be in many categories. Justin's solution is certainly better than nothing, but I was trying to solve it using session variables. Wouldn't or couldn't there be something set in the session that indicates which category was last active? Of course, something different would be needed in the case where the product is found through a search without going through categories.
Justin, I also have many levels of categories on my site and have found many issues unique to this situation. I would love to collaborate some of our findings. I'm sure we can help each other. Oddly enough, I didn't have the same problem you had with it trying to use shopdisplayproducts when you really wanted shopdisplaycategories. I say that's odd, because I've had that problem in many other places, especially in shopcatetorylist.asp.
I have been planning to put this breadcrumb issue and several others in the suggestions for future releases.
You guys have gotten me energized!
Nathan
|
|
|
Justin
VP-CART New User
87 Posts |
Posted - April 17 2004 : 17:05:28
|
another consideration is that for searches, only the original "home -->" part of the breadcrumbs comes up.
I noticed vpasp gives search display listings a heading that says "Products." Also, since every situation except product extended descriptions the vpasp standard heading is actually the same as the final breadcrumb, I thought that I was sort of re-inventing the wheel, having the breadcrumbs write it out each time. So I started thinking that I might just finish the breadcrumbs at the category (which would still be a link) and then let the existing vpasp code display the final, non-link, breadcrumb.
Of course, extended descriptions still need to be hacked. I'd be interested in your solutions so far.
JL
|
|
|
jsbeads
Starting Member
USA
39 Posts |
Posted - April 21 2004 : 09:41:53
|
Okay I guess I am just stupid. How do you make this function call?
I included the breadcrumbs file then I call GenerateBreadCrumbs(dbc,cat_id,->,False)
This is wrong --- what an I doing?
|
|
|
Justin
VP-CART New User
87 Posts |
Posted - April 22 2004 : 04:13:04
|
It's great to know people actually *use* the code here <g>
Anyway, try putting your seperator in quotes.
JL
|
|
|
al100
Starting Member
United Kingdom
20 Posts |
Posted - April 22 2004 : 07:30:14
|
Hi Justin
I have created the breadcrumb.asp file and included it in shopdisplaycategories & shop but dont know where or how to add the call for this code.
Any clues would be great
Thanks
Alan
|
|
|
Justin
VP-CART New User
87 Posts |
Posted - April 22 2004 : 20:59:41
|
I used:
response.write(GenerateBreadCrumbs(dbc,highercategoryid," > ",false))
from shopdisplaycategories.
JL
|
|
|
al100
Starting Member
United Kingdom
20 Posts |
Posted - April 23 2004 : 02:19:50
|
hi Justin
Well I added the call but now get
Microsoft VBScript runtime error '800a000d'
Type mismatch: '[undefined]'
/shop/shopdisplaycategories.asp, line 264
I also had to Dim Generatebreadcrums - as variable was undefined
Any clues where I am going wrong -
Alan
PS Can't believe support has not sorted this out for us uninitiated and after all the negaive remarks throughout this forum regarding this breadcrumb problem
|
|
|
support
Administrator
4679 Posts |
Posted - April 23 2004 : 02:29:14
|
We try not to get involved in user modifications exactly for the reasons you are having problems. We fully test and integrate these types of things into VP-ASP and do not expect you to be ASP experts.
But we are not going to get involved in debugging, fixing or in any other way resolving issues for code that we did not write.
We have reviewed this forum and have totally rewritten the "breadcrumbs" for both categories and products in the upcoming VP-ASP 5.50.
Howard Kadetz VP-ASP
|
|
|
Justin
VP-CART New User
87 Posts |
Posted - April 23 2004 : 05:49:20
|
I have to say I agree with Howard - this isn't really a support issue. Maybe there *is* an issue with another _supported_ version of the breadcrumbs that I'm not aware of.
I'll also add that all the code on these forum pages is use-at-your-own-risk. I just uploaded my hack because I thought it might have something useful in there for some people. It's not for everyone - an experienced programmer would most likely take one look at my code and shake his head in disbelief at all the bad programming practices I've employed. But it might also be enough for that programmer to put together something useful for one of his clients.
The commercial programming industry is largely market-driven, and as such bad code makes it out into the wild more often than less.
As for the problems you're having now, it's hard for me to comment further without seeing all your code. Though I noticed you had a typo in your above post (breadcrums). It might be something as simple as this.
JL
|
|
|
al100
Starting Member
United Kingdom
20 Posts |
Posted - April 24 2004 : 03:25:52
|
Hi Guys
Don't get me wrong, I really appreciate the code people submit and the time and effort people put into assisting one another on this site.
I also think VP-ASP is probably the best cart around, with definately the best support.
I am really pleased the breadcrumb issue will be sorted in the next version as it is possibly the only thing that lets the product down -talking of which when can we expect Ver 5.50
Alan
|
|
|
greatphoto
VP-CART Super User
USA
304 Posts |
Posted - April 25 2004 : 07:04:54
|
I think that Alan and the rest of us understand that Support can't help debug each person's modifications. That is a function of this forum. The forum is great since it allows users to help each other with code and other problems.
Rather, I interpreted Alan's support remarks as a plea for VP-ASP to change the design of the product if it is not meeting customer's needs. Although the breadcrumb feature works as was intended, the industry standard for breadcrumbs is for them to show up on all pages and for them to link to the page named. Any other operation appears like a bug, even though its not. Howard's final statement that "We have reviewed this forum and have totally rewritten the "breadcrumbs" for both categories and products in the upcoming VP-ASP 5.50" addresses this very nicely. Thanks Howard!
|
|
|
jbtinker
Starting Member
6 Posts |
Posted - January 14 2005 : 05:55:23
|
Hey... I am trying to customize the breadcrumbs in Version 5.50 and cant find where they are generated from... anyone know?
|
|
|
greatphoto
VP-CART Super User
USA
304 Posts |
Posted - January 14 2005 : 20:21:02
|
quote:
Hey... I am trying to customize the breadcrumbs in Version 5.50 and cant find where they are generated from... anyone know?
Its a subroutine called GenerateCategoryLinks. It shows up in two places: line 220 of shopdisplaycategories.asp and line 440 of shopdisplayproducts.asp
Depending on what mod you have in mind, you'll likely want to change both places, or move the subroutine out to a separate file that you then <!--#include --> in both original files.
|
|
|
|
Topic |
|