Welcome, Guest ( Customer Panel | Login )




 All Forums
 VPCart Forum
 Add-ons for VP-ASP
 Sub categories and product on categorydisplay page
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

venkat
Starting Member

5 Posts

Posted - December 24 2008 :  01:52:43  Show Profile  Reply with Quote
Hi guys, i have a scenarion here.

in the shopping cart iam building now, i have categories and subcategories on them. plus i have to add some products directly under that main categories which will also have sub catagories.

as per the design of templates in tmp_categorytemplate.htm its showing only subcategories under the category, where i want to display the products also under that main category same like in tmp_productformat.htm.
when i try to add the feilds tmp_productformat.htm to tmp_categorytemplate.htm its saying feild name is not in database.

guys i hope somebody would have came across this situation, please help me out how can i handle this.

Thanks

Venkat

Edited by - venkat on December 24 2008 01:54:33

jal
Starting Member

8 Posts

Posted - December 26 2008 :  11:01:05  Show Profile  Reply with Quote
Hi venkat; I think I had the exact same issue that you're talking about here, and I resolved it by writing some code to allow category navigation within shopdisplayproducts.asp.

With this, whenever you click a category, it goes to shopdisplayproducts.asp, and shows links to subcategories at the top, with products below.

This allows you to display products in main categories (ones with subcategories), as well as still showing navigation to subcategories.

If this is what you are looking for, I'll put it up for download. It's not complicated.

Jared Lindsey,
Private Developer

Edited by - jal on December 26 2008 11:17:33
Go to Top of Page

saki
VP-CART New User

82 Posts

Posted - December 29 2008 :  21:06:23  Show Profile  Reply with Quote
yes, I would be interested in this. Please Post

Go to Top of Page

jal
Starting Member

8 Posts

Posted - December 30 2008 :  17:05:59  Show Profile  Reply with Quote
OK. Here it is. I'm using 6.50--not sure this will work with previous releases.

Put this subroutine somewhere in shopdisplayproducts.asp (probably toward the bottom is best.)

Sub ShowLinksToSubcategories(HigherCategoryID, dbc)
  ' JAL 7/Nov/2007 15:51 
  ' Subroutine to display links to subcategories like shopdisplaycategories.asp 
	dim sql, rs, sqlWhere, recordCount, DisplayImages
	DisplayImages=getconfig("xdisplaycategoryimages")
	
	'Generate the WHERE clause for SQL statements
	sqlWhere = " where highercategoryid=" & HigherCategoryID
	if getconfig("xproductmatch")="Yes" then
	'VP-ASP 6.50 - enhanced product matching
	 Generateproductmatchsqlsubs sqlWhere          ' In shopproductsubs
    	'sql=sql & " and (productmatch='" & xproductmatch & "' or productmatch is null)"
	end if 
	if getconfig("xproductmatchcustomer")="Yes" then
   		if GetSess("CustomerProductGroup")<>"" then
      			sqlWhere=sqlWhere & " and customermatch='" & getsess("customerProductgroup") & "'"
    		end if  
	end if    
	If getconfig("xselectproductsbylanguage")="Yes" and getsess("language")<>"" then
		sqlWhere=sqlWhere & " and (catlanguage='" & getsess("language") & "'"
		sqlWhere=sqlWhere & " or catlanguage is null)"
	end if
	sqlWhere=sqlWhere & " order by " & Getconfig("xsortcategories")
	
	'Generate SQL statement to get record count
	sql="Select count(*) as nrecords from categories " & sqlWhere
	set rs = dbc.execute(sql)
	if not rs.eof then 
		recordCount = cint(rs("nrecords"))
	else
		exit sub
	end if
	
	'Generate SQL statement to get actual records
	sql="Select * from categories " & sqlWhere
	set rs = dbc.execute(sql)
	if rs.eof then exit sub

	'Get the number of columns for table, 
	dim tblRowCount,columns
	tblRowCount = ceiling(recordCount / 6)
	'Get the number of columns
	columns = ceiling(recordCount / tblRowCount)
	
	response.write("<table style=""width: 100%;"" width=""100%"" border=""0"" align=""center""><tr>")
	dim recordIdx
	recordIdx=0
	do while not rs.eof
		recordIdx=recordIdx+1
			response.write "<td align=""center"" valign=""top"">"
			response.write "<p style=""line-height:100%; margin-top:0; margin-bottom:0;"" align=""center"">"
			response.write "<a href=""/store/shopdisplayproducts.asp?id=" & rs("categoryid") & "&cat=" & _
			  server.URLEncode(rs("catdescription")) & """ style=""font-size: smaller;"">"
			if DisplayImages="Yes" then response.write "<img border=""0"" src=""" & rs("catimage") & """ /><br />"
			response.write "" & rs("catdescription") & "</a><br />"
			response.write "</p></td>"
		if recordIdx mod columns = 0 then response.write "</tr><tr>"
		rs.movenext	
	loop
	response.write "</tr></table>"
	rs.close
End Sub


Then, at the place where you want the category list displayed, insert the following:

If not isempty(CAT_ID) then 
	ShowLinksToSubcategories CAT_ID, dbc
end if


I would put that in right after the breadcrumbs, around line 155 or so, but it doesn't really matter where, as long as CAT_ID has a value and dbc is connected.

You'll probably want to change its appearance, etc...

Also, if you want to see category images, make sure xdisplaycategoryimages=Yes

I think that's all. Hope it helps.

Edited by - jal on December 30 2008 17:10:52
Go to Top of Page

jal
Starting Member

8 Posts

Posted - December 30 2008 :  17:16:01  Show Profile  Reply with Quote
I forgot to mention that the above subroutine assumes that VPASP is installed in a /store directory. If that's a problem, you can just change all the references. Let me know if it works out for you.
Go to Top of Page

sklucas
Starting Member

USA
2 Posts

Posted - January 01 2009 :  16:37:56  Show Profile  Reply with Quote
I'm putting together a quilting shop that has multiple fabrics, I want to put together a main category, with sub categories, using the same product in multiple locations, based on different fields. Here's sort of how it would look.

Main category:
Fabrics - would display all fabrics

Sub categories:
Designer - based on what I will put in the pother1 field
Color = based on what I will put in the pother2 field
Safe for children's sleepwear = based on what I will put in pother3
Fabric type = pother4
Country = pother5

Now could I put the pother in the category product matach field? or would I have to put together an asp that is separate for each of the groups.




Go to Top of Page

interface engineer
Starting Member

USA
30 Posts

Posted - September 24 2009 :  15:55:46  Show Profile  Visit interface engineer's Homepage  Reply with Quote
Jal - thanks for posting this customization. I need to show category links on my shopdisplayproducts.asp page as well.

I'm getting the following error w/ your code tho - any ideas?

Microsoft JET Database Engine error '80040e21'

You tried to execute a query that does not include the specified expression 'catdescription' as part of an aggregate function.

shopdisplayproducts.asp, line 602

www.interfaceengineer.com

Edited by - interface engineer on September 28 2009 18:12:24
Go to Top of Page

interface engineer
Starting Member

USA
30 Posts

Posted - September 28 2009 :  18:11:36  Show Profile  Visit interface engineer's Homepage  Reply with Quote
VPASP support helped me resolve the error. Here is the corrected code:

Sub ShowLinksToSubcategories(HigherCategoryID, dbc)
' JAL 7/Nov/2007 15:51
' Subroutine to display links to subcategories like shopdisplaycategories.asp
dim sql, rs, sqlWhere, recordCount, DisplayImages
DisplayImages=getconfig("xdisplaycategoryimages")
'response.write HigherCategoryID
'Generate the WHERE clause for SQL statements
sqlWhere = " where highercategoryid=" & HigherCategoryID
if getconfig("xproductmatch")="Yes" then
'VP-ASP 6.50 - enhanced product matching
Generateproductmatchsqlsubs sqlWhere ' In shopproductsubs
'sql=sql & " and (productmatch='" & xproductmatch & "' or productmatch is null)"
end if
if getconfig("xproductmatchcustomer")="Yes" then
if GetSess("CustomerProductGroup")<>"" then
sqlWhere=sqlWhere & " and customermatch='" & getsess("customerProductgroup") & "'"
end if
end if
If getconfig("xselectproductsbylanguage")="Yes" and getsess("language")<>"" then
sqlWhere=sqlWhere & " and (catlanguage='" & getsess("language") & "'"
sqlWhere=sqlWhere & " or catlanguage is null)"
end if
'sqlWhere=sqlWhere & " order by " & Getconfig("xsortcategories")

'Generate SQL statement to get record count
sql="Select count(*) as nrecords from categories " & sqlWhere
set rs = dbc.execute(sql)
if not rs.eof then
recordCount = cint(rs("nrecords"))
else
exit sub
end if

'Generate SQL statement to get actual records
sql="Select * from categories " & sqlWhere
set rs = dbc.execute(sql)
if rs.eof then exit sub

'Get the number of columns for table,
dim tblRowCount,columns
tblRowCount = ceiling(recordCount / 6)
'Get the number of columns
columns = ceiling(recordCount / tblRowCount)

' response.write("<table style=""width: 100%;"" width=""100%"" border=""0"" align=""center""><tr>")
'response.write "<br clear=""all"">"
dim recordIdx
recordIdx=0
do while not rs.eof
recordIdx=recordIdx+1
' response.write "<td align=""center"" valign=""top"">"
' response.write "<p style=""line-height:100%; margin-top:0; margin-bottom:0;"" align=""center"">"
response.write "<a href=""shopdisplayproducts.asp?id=" & rs("categoryid") & "&cat=" & _
server.URLEncode(rs("catdescription")) & """>"
' if DisplayImages="Yes" then response.write "<img border=""0"" src=""" & rs("catimage") & """ /><br />"
response.write "" & rs("catdescription") & "</a><br />"
'response.write "</p></td>"
' if recordIdx mod columns = 0 then response.write "</tr><tr>"
rs.movenext
loop
' response.write "</tr></table>"
rs.close
End Sub

Function Ceiling(intNumber)
Dim dblNumber
dblNumber = CDbl(intNumber)
If Int(dblNumber * 10) MOD 10 > 0 Then
Ceiling = Int(dblNumber) + 1
Else
Ceiling = Int(dblNumber)
End If
End Function

www.interfaceengineer.com
Go to Top of Page

interface engineer
Starting Member

USA
30 Posts

Posted - September 30 2009 :  18:28:15  Show Profile  Visit interface engineer's Homepage  Reply with Quote
update: the 'ceiling' function is only needed if you do not have your products nested in sub categories. I ended up changing the DB architecture and had to go back to JAL's original code to make it work.

Cheers

www.interfaceengineer.com
Go to Top of Page

borisvel
Starting Member

Slovenia
47 Posts

Posted - May 05 2012 :  06:48:20  Show Profile  Visit borisvel's Homepage  Reply with Quote
Hi,

i use this piece of code, thanks a lot.

I wonder if someone can complete code it this way, that subcategories names could be translated automatically when language switching takes place.

Many thanks for help in advance.

Boris

www.finechance.com www.personaliziranadarila.si www.lingerie.si
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000
0 Item(s)
$0.00