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
 GenerateCategoryLinks from displayproducts.asp?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

alla
Starting Member

10 Posts

Posted - March 03 2004 :  11:57:41  Show Profile  Visit alla's Homepage  Reply with Quote
Instead of displaying the current category on top of the products page, I wanted to display the current category, and the categories previous to it kind of like in shopdisplaycategories.asp

For example, right now it displays:

CATEGORYCURRENT

I want it to display:

CATEGORY1> CATEGORY2> CATEGORYCURRENT

I copied the GenerateCategoryLinks sub into its own .asp file, and included it in the beginning of both shopdisplaycategories.asp and shopdisplayproducts.asp so that I can call it from either one. I modified it slightly so that CATEGORYCURRENT doesn't have a link attached to it (kind of redundant linking to the page you're already at, right?)

Anyway, everything was working OK, and I didn't really notice a problem until I tried navigating through the different pages in shopdisplayproducts.asp. If I move anywhere outside of the first page, I get the following error:


Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '='.

/generatecategorylinks.asp, line 15



Line 15 is Set rs=dbc.execute(catsql), you can find it in shopdisplaycategories.asp if you want to see what other code surrounds it.

To be more precise, that error appears anytime there is a variable sent along with a url (ex: /shopdisplayproducts.asp?page=1).

What seems to be the problem?





Edited by - alla on March 03 2004 11:59:12

alla
Starting Member

10 Posts

Posted - March 03 2004 :  12:07:11  Show Profile  Visit alla's Homepage  Reply with Quote
Actually, now that I look more into it, the problem is probably not because there are variables sent with the URL, but because there are variables missing from the URL.

Again, I'm new to all this ASP stuff, so bear with me.

The URL that the sub recognizes ends like this: shopdisplayproducts.asp?id=187&cat=Desktop+Cases

I assume that line 15 mentioned in the previous post uses the cat variable. If I navigate back and forth through the pages, the variables clear and it only sends the page information with the url: shopdisplayproducts.asp?page=1

Now, would it be safe to assume that all I have to do is change the navigation links so that they include the category and id information as well? For example: shopdisplayproducts.asp?id=187&cat=Desktop+Cases&page=1

Roman



Edited by - alla on March 03 2004 12:07:49
Go to Top of Page

alla
Starting Member

10 Posts

Posted - March 03 2004 :  14:25:36  Show Profile  Visit alla's Homepage  Reply with Quote
Ok, I finally figured it all out. Incase anyone else wants to do something similar, here is what I did:


!!!PLEASE MAKE BACKUPS OF ANY FILES YOU ARE GOING TO CHANGE SO THAT IT IS EASY FOR YOU TO REVERT BACK TO ORIGINALS IF YOU DON'T LIKE THE CHANGE!!!

1. I copied the GenerateCategoryLinks sub from shopdisplaycategories.asp into its own file, and saved it as generatecategorylinks.asp. I modified the sub slightly so that:

  • All the required variables are declared

  • The current page in the category links will not have a link, since that would just be redundant



The code looks like this:

<%
Sub GenerateCategoryLinks
dim mylink
dim highercategoryid
highercategoryid=request("id")
If not isnumeric(highercategoryid) then
highercategoryid=""
end if
dim highercatid, cats(10),catids(10), i
dim cathead, more, catsql, rs
dim id,name
highercatid=highercategoryid
cathead=""
catsql="select * from categories where categoryid=" & highercatid
Set rs=dbc.execute(catsql)
highercatid=rs("highercategoryid")
name=rs("catdescription")
id=rs("categoryid")
i=0
More=True
if highercatid=0 then
mylink=name
cats(i)=mylink
i=i+1
more=false
else
mylink=name
cats(i)=mylink
i=i+1
end if
Closerecordset rs
Do while more=True
catsql="select * from categories where categoryid=" & highercatid
Set rs=dbc.execute(catsql)
If not rs.eof then
highercatid=rs("highercategoryid")
name=rs("catdescription")
id=rs("categoryid")
mylink="<a HREF=""shopdisplaycategories.asp?id=" & highercatid & "&cat=" & Server.URLEncode(name) & """>" & name & "</a>"
cats(i)=mylink
i=i+1
if highercatid=0 then
more=false
end if
else
more=false
end if
Closerecordset rs
loop
For i = 0 to i-1
If cathead="" Then
cathead = cats(i)
else
cathead= cats(i) & subcatseparator & cathead
end if
next
response.write subcatheader & cathead & subcatheaderend
end sub
%>


2. After I did that, I removed the GenerateCategoryLinks sub from shopdisplaycategories.asp, and added the following include to shopdisplaycategories.asp and shopdisplayproducts.asp:
<!--#include file="generatecategorylinks.asp"-->


3. Next, I found the line in shopdisplayproducts.asp that generated the current category text on top of the page. It looks like this:
response.write prodheaderfont & header & prodheaderfontend'

I commented that line out, and replaced it with:
GenerateCategoryLinks





Edited by - alla on March 03 2004 14:34:08
Go to Top of Page

alla
Starting Member

10 Posts

Posted - March 03 2004 :  14:30:14  Show Profile  Visit alla's Homepage  Reply with Quote
4. At this point I thought I was done, but later I found out if you have a navigation bar up top, it will return an error when you try to go through the pages. I made some changes to the PageNavBar sub in shop$db.asp (note: the changes were made to the first occurance of PageNavBar sub, not the second one): http://world.anarchy.com/~disarray/shop$db-mod.txt (the code was too long to post in a reply).

Also please note that the changes were made to the text navigation bar, not to the image navigation bar. I don't use the previous/next images on my page, so I felt no need to edit them. If you use them, it shouldn't be too hard to figure out how to apply this code to the PageNavBarNext sub for images. Last but not least, my PageNavBar sub was already slightly modified earlier with some code I found on this forum that allowed me to have previous/next links in TEXT along with the numbered page links. I figured I should make you aware of this if you decide to copy/paste everything.


Here is what it looks like in the end (don't worry about the design, I haven't started on that yet ) http://world.anarchy.com/~disarray/vpaspmod.jpg

Roman

Edited by - alla on March 03 2004 14:39:48
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000