Welcome, Guest ( Customer Panel | Login )




 All Forums
 VPCart Forum
 Problems and bugs
 shopnavcategories.asp
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mrbob
Starting Member

9 Posts

Posted - May 05 2007 :  20:53:39  Show Profile  Reply with Quote
Hi there,

I needed shopnavcategories.asp to function like shopcategorylist.asp as referenced here:

https://www.vpasp.com/helpnotes/shopexd.asp?id=879

so that categories open shopdisplaycategories.asp and sub-categories open shopdisplayproducts.asp

the shopnavcategories.asp file in the above helpnotes doesn't do this, so I fixed it as shown below. I hope this helps anyone

<%
dim navdbc 

'***************************************************************************
sub DisplayNavcategories
shopopendatabaseP navdbc
dim sql, rs, level, rc, catdescription, spacing, categoryid
dim highercategoryid, hassubcategory
highercategoryid=0
GenerateNavsql sql, highercategoryid
set rs=navdbc.execute(sql)
CreateNavCattable
do while not rs.eof
    GetNavcategoryfields rs,categoryid, hassubcategory, catdescription, rc
    If rc=0 then 
       spacing=0
       FormatNavcategory categoryid, catdescription, spacing, hassubcategory
        If hassubcategory<>"" then 
          FormatNavsubcategories categoryid,spacing
       end if   
    end if
    rs.movenext   
loop
closerecordset rs
Response.write "</td></tr></table>"
shopclosedatabase navdbc
end sub

Sub CreateNavcattable
Response.write "<table width='100%'>"
response.write "<tr>"
response.write "<td align=left>"
end sub
'
Sub GetNavcategoryfields (rs, categoryid, hassubcategory, strcategory, rc)
   dim strcathide
   categoryid=rs("categoryid")
   strcategory=rs("catdescription")
   hassubcategory=rs("hassubcategory")
   If isnull(hassubcategory) then
      hassubcategory=""
   end if
   strcathide=rs("cathide")          ' hide field
   if isnull(strcathide) then
      rc=0
   else
      rc=4
   end if
end sub

Sub GenerateNavsql (sql, highercategoryid)
SQL="Select * from categories "
sql = Sql & " where highercategoryid=" & highercategoryid
if getconfig("xproductmatch")="Yes" then
     sql=sql & " and productmatch='" & xproductmatch & "'"
end if 
if getconfig("xproductmatchcustomer")="Yes" then
   if GetSess("CustomerProductGroup")<>"" then
      sql=sql & " and customermatch='" & getsess("customerProductgroup") & "'"
    end if  
end if    
Handle_selectnavcategoriesbylanguage sql
sql=sql & " order by " & Getconfig("xsortcategories") 
end sub

Sub FormatNavcategory (id, name, spacing, hassubcategory)
dim i
If spacing>0 then
  for i = 0 to spacing
     response.write "  "
  next
end if   
  
if hassubcategory <> "" then
	response.write "<a href=""shopdisplaycategories.asp?id=" & id & "&cat=" & Server.URLEncode(name) & """>" &  name & "</a>"  & "<br />" & vbcrlf

else
 
	response.write "<a HREF=""shopdisplayproducts.asp?id=" & id & "&cat=" & Server.URLEncode(name) & """>" &  name & "</a>"  & "<br>" & vbcrlf

end if

end sub

Sub FormatNavsubcategories (categoryid, spacing)
dim sql, rs, rc, catdescription, hassubcategory
GenerateNavsql sql, categoryid
Set rs=navdbc.execute(sql)
spacing=spacing+1
do while not rs.eof
    GetNavcategoryfields rs,categoryid, hassubcategory, catdescription, rc
    If rc=0 then 
       FormatNavcategory categoryid, catdescription,  spacing, hassubcategory
       If hassubcategory<>"" then 
          FormatNavsubcategories categoryid, spacing
       end if   
    end if
    rs.movenext        
loop
spacing=spacing-1    
closerecordset rs
end sub

sub Handle_selectnavcategoriesbylanguage (sql)
If getconfig("xselectproductsbylanguage")="Yes" and getsess("language")<>"" then
     sql=sql & " and (catlanguage='" & getsess("language") & "'"
     sql=sql & " or catlanguage is null)"
end if    
end sub
%>

bmf
Starting Member

Australia
2 Posts

Posted - May 06 2007 :  00:02:45  Show Profile  Reply with Quote
Peoples,

I tried the above fix, but ended up with the error:

Microsoft VBScript compilation error '800a0411'
Name redefined
/shopnavcategories.asp, line 2

dim navdbc
----^

I can not find it defined anywhere else within the site.

Any guidance would be great.
Go to Top of Page

mrbob
Starting Member

9 Posts

Posted - May 06 2007 :  03:19:17  Show Profile  Reply with Quote
hmm, I don't get that error. my first guess would be that maybe you have 2 instances of shopnavcategories.asp as include files.

I have placed

<!-- #include file="shopnavcategories.asp" -->


in shop$db.asp and use

<%DisplayNavcategories%>


to call the menu (which I have in shoppage_header.htm)
Go to Top of Page

bmf
Starting Member

Australia
2 Posts

Posted - May 20 2007 :  05:22:12  Show Profile  Reply with Quote
Well got it working.

Can you help in adding indentation into the menu structure?
Such as:
Main Cat1
Sub Cat1 (indented in 2 spaces)
Sub Cat2 (indented in 4 spaces)
Main Cat2
Sub Cat 1 (indented in 2 spaces)
Sub Cat2 (indented in 4 spaces)
Or even if it can have expandable menu structure?

Edited by - bmf on May 20 2007 05:23:15
Go to Top of Page

LisaGriff
VP-CART New User

USA
90 Posts

Posted - May 20 2007 :  23:26:53  Show Profile  Visit LisaGriff's Homepage  Reply with Quote
I found a menu called The Simple Tree Menu on dynamicdrive.com that I adapted and easily integrated that expands to show the subcategories.
It was pretty simple to do and it uses the categories from the category navigation routine by inserting the script code
after the call to the routine in the shop header file as shown below in how I have mine coded.

Then all you have to do is make a couple of changes in shopnavcategories.asp & tweak the css settings in the shop.css file
and the css file included with the menu to get the look you want. Worked like a charm but it did take a bit of css tweaking for me.
You can see it on my test site
http://test.griffshortcuts.com/shop650


Download the menu files and follow installation directions then

You will need the shopnavcategories.asp file from the referenced example in the first posting
or, as I am using, the one from the fly-out menu add-on.

around line 12 in shopnavcategories.asp find
set rs=navdbc.execute(sql)


add underneath it
Response.write "<ul id=""catnav"" class=""treeview"">" & vbcrlf


around line 83 in shopnavcategories.asp find
If hassubcategory<>"" And showsubcats="Yes"  then


add underneath it
Response.write "<ul id=""catnav"" class=""treeview"">"


my code in the shop header file

<!-- START CATEGORY BOX -->
				
<!--<h2><%=getlang("langcommoncategories")%></h2>-->
		
<%DisplayNavcategories%>
					
<script type="text/javascript">

//ddtreemenu.createTree(treeid, enablepersist, opt_persist_in_days (default is 1))
ddtreemenu.createTree("catnav", true, 2)

</script>		
			
<!-- END CATEGORY BOX -->


Hope this helps and that it isn't too confusing.

Edited by - LisaGriff on May 20 2007 23:58:20
Go to Top of Page

goshen
VP-CART New User

132 Posts

Posted - May 21 2007 :  21:32:29  Show Profile  Reply with Quote
your test site is not showing. Can you check the validity of the URl so we can see? Thanks
Go to Top of Page

LisaGriff
VP-CART New User

USA
90 Posts

Posted - May 21 2007 :  22:25:23  Show Profile  Visit LisaGriff's Homepage  Reply with Quote
oops - sorry for the typo

http://test.griffsshortcuts.com/shop650

Edited by - LisaGriff on May 21 2007 22:27:00
Go to Top of Page

goshen
VP-CART New User

132 Posts

Posted - May 29 2007 :  23:14:52  Show Profile  Reply with Quote
Thanks...awesome
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