Author |
Topic |
|
greatphoto
VP-CART Super User
USA
304 Posts |
Posted - April 19 2004 : 15:52:40
|
Please extend the xdisplaycategoryfiles/catextra feature of product views to also work on category views.
Product pages displayed using shopdisplayproducts.asp already allow the insertion of custom html at the top of the view of all the products in the category. This is very powerful since the user can insert text, graphics, links, tables, etc without writing any ASP. They even have some basic impact over the appearance of the entire page. Each category of products can be customized separately. There are many applications for this, but probably the most standard is being able to introduce each category of products with some explanatory text and images. This is all enabled by using xdisplaycategoryfiles=yes with a filename in the catextra field of each category of products to be customized.
Unfortunately, this same flexibility is not offered on category views that show sub-categories rather than products. I have noticed that many VP-ASP customers do not have many sub-categories so they won't be sensitive to this limitation. However, a growing number recognize the importance of organizing their products hierarchically if they have a broad range of many products. One suggestion is to hard-code specific category information into the ASP code to get the presentation they require.
A more flexible approach that is usable by all customers without requiring knowledge of ASP is just to extend the feature already created for product views to also work on category views. I have already done this on my own site, and am sharing the idea to broaden the usability of VP-ASP for others. I'll share the code with any VP-ASP customer who wants it. Afterall, it is really just expanding the application of some code already in the product.
The way it works is simple: set xdisplaycategoryfiles=YES. Create an HTML or text file with the data you wish to see at the top of the category, and place the name of the file in the catextra field of the category. When you load that category view, your text shows up at the top!
|
|
Jamie
Starting Member
United Kingdom
16 Posts |
Posted - December 29 2004 : 12:42:48
|
I would really appreciate the code for this, as category display is driving me to distraction! I'm brand new to vpasp and it is a steep learning curve.
thanks
Jamie
|
|
|
greatphoto
VP-CART Super User
USA
304 Posts |
Posted - December 30 2004 : 12:45:59
|
I've been thinking of the best way to share this. Its really not hard, but the way I did it may not be the best for everyone. I'll do this in several posts so its separated more clearly.
First, you need to make a modified version of the ShowCategoryImage subroutine found in shopdisplayproducts.asp be accessible to shopdisplaycategories.asp. I did this by placing a modified copy in a separate new file called shopdisplaysubs.asp. (This is the file I use for common subroutines that need to be used in multiple other files.)
I'll paste the contents of this modified subroutine in my next post, and you'll be free to add it to a new file like mine, or dump it directly into shopdisplaycategories.asp.
BTW, does anyone know how to insert leading spaces in this forum? When I paste code with nice hierarchical spacing for readability, the forum removes them and it looks poor. I think what we need is something similar to the <pre> preformatted text tag in HTML.
Nathan
|
|
|
greatphoto
VP-CART Super User
USA
304 Posts |
Posted - December 30 2004 : 13:45:06
|
Instructions to add this feature to either V5.0 or V5.50
1) Okay, here's the subroutine to place into a new file called shopdisplaysubs.asp, or just paste directly into the bottom of shopdisplaycategories.asp. The next post will share which changes to make to shopdisplaycategories.asp to make use of this subroutine.
<% '****************************************************************** ' Nathan Bailie ' Copy/modified/pasted this routine from shopdisplayproducts ' It displays the category picture and text from a file specified by ' the catextra field of the category if xdisplaycategoryfiles is ' set to yes. ' Was ShowCategoryImage in shopdisplayproducts.asp, but I added the ' capture of cat_id in the same way it was captured elsewhere in ' shopdisplayproducts and passed into this routine globally. I also ' remove the display of the picture as it wasn't working right here, ' and I didn't really want it anyway. If I want the picture, I'll ' include it in the header manually. '****************************************************************** Sub ShowCategoryCatExtra Dim ImageFileName, description, i Dim rs Dim query imagefilename="" CAT_ID = Request("id") ' category id If not isnumeric(CAT_ID) then CAT_ID="" ' hacker fix If cat_id="" then exit sub If getconfig("xDisplayCategoryImages")="Yes" or getconfig("xdisplaycategoryfiles")="Yes" Then query = "select * from categories where categoryid = " & cat_id set rs = dbc.execute(query) If not rs.EOF Then imagefilename = rs("catimage") description=rs("catextra") if isnull(imagefilename) then imagefilename="" end if if isnull(description) then description="" end if end if closerecordset rs else exit sub end if 'If getconfig("xDisplayCategoryImages")="Yes" and imagefilename<>"" then ' response.write "<p><center><img border='0' src=" & ImageFileName & "></center></p>" 'end if If getconfig("xdisplaycategoryfiles")="Yes" and description <>"" then dim readarray(500), readcount readcount=0 ShopReadFile description,ReadArray,readcount 'debugwrite "readcount=" & readcount & " file=" & description if readcount=0 then exit sub response.write "<br>" for i = 0 to readcount-1 response.write readarray(i) & vbcrlf next end if End Sub %>
Note: If you paste this directly into shopdisplaycategories.asp, then you should delete the leading "<%" and the trailing "%>"
Edited by - greatphoto on December 30 2004 16:33:20 |
|
|
greatphoto
VP-CART Super User
USA
304 Posts |
Posted - December 30 2004 : 16:29:43
|
Changes to shopdisplaycategories.asp
2) Add the following lines to shopdisplaycategories.asp just after line 3 (before the "<%")
<!--#include file="shopdisplaysubs.asp"--> <!--#include file="shopreadfile.asp"-->
If you pasted directly into shopdisplaycategories.asp instead of creating the new file called shopdisplaysubs.asp, then leave out the first line since you can't include a file that doesn't exist. ;-)
3) We'll next edit the CategoryHeader subroutine in shopdisplaycategories.asp (starts at line 142 in V5.50 and line 150 in V5.0). It normally looks something like this (V5.0 is missing the use of the header variable, but is otherwise the same as this):
Sub CategoryHeader dim header If highercategoryid<>0 then Generatecategorylinks header else response.write catHeader & getlang("LangCat01") & catheaderend & "<br><br>" end if response.write CatTable end sub
You'll add the lines in red to make it look like this:
Sub CategoryHeader dim header If highercategoryid<>0 then Generatecategorylinks header else response.write catHeader & getlang("LangCat01") & catheaderend & "<br><br>" end if ' NJB 4-18-04, 11-8-2004 Adding import of text from the file indicated ' in catextra dependent on xdisplaycategoryfiles ShowCategoryCatExtra ' response.write CatTable end sub
__________________ In the next post, I'll show what to do in the database category table to specify custom HTML to be added to the top of the category. A different HTML can be used for each category, or multiple categories can reference the same HTML file. Its all up to you.
Edited by - greatphoto on December 31 2004 07:34:16 |
|
|
greatphoto
VP-CART Super User
USA
304 Posts |
Posted - December 30 2004 : 22:17:59
|
Cart Configuration
4) This last step is just the cart config that you need to actually use your new feature. Its actually already documented in the design guide. The changes above just extend the concepts already documented to now also work for category views instead of just product views.
V5.50 reference: See section 7.3 on page 29 of VP-ASP Developer's Guide which is available here: http://www.vpasp.com/virtprog/vpasp550developer.pdf
V5.0 reference: See section 7.3 on page 23 of VP-ASP Developer's Guide which is available here: http://www.vpasp.com/virtprog/vpasp500developer.pdf
So, just set Xdisplaycategoryfiles = Yes
Then, for each category where you want to add a category specific html file to the top of the category display, edit the corresponding record of the category table and place the name of an html file in the catextra field. Multiple categories can use the same name if you wish the same header html to appear in multiple places, or every one can be unique.
Each HTML file can contain standard HTML constructs including pictures and links to other pages.
|
|
|
greatphoto
VP-CART Super User
USA
304 Posts |
Posted - December 30 2004 : 22:34:29
|
Please let me know whether you find this helpful. I've had it working on our site for 8 months, so I'm just providing it to help out the VP-ASP community of users. I have to admit that I was reluctant to share it as it is a nice differentiator for my site. However, I've always felt that it should have been supported by Virtual Programming from the start. So, I'm just filling in a gap they left by reapplying their own code.
Then again, I think one could make some good money filling in all the gaps...
|
|
|
Jamie
Starting Member
United Kingdom
16 Posts |
Posted - December 31 2004 : 10:20:57
|
Many thanks for sharing this very useful peice of code with us all, it works very well and takes our shop a step closer to being what we want.
|
|
|
calliope
Starting Member
45 Posts |
Posted - June 04 2005 : 09:16:11
|
I like your idea very much and many thanks for sharing. Unfortunately we have not been able to implement it because we don't know how to link the picture of the product in tmp_productthumbnail.htm to the category display. In other words, our current path is: homepage --> category with products displayed using tmp_productthumbnail --> extended description page.
We can't figure out how to insert the new category so it would become: homepage --> category with products displyed using tmp-productthumbnail --> new 'greatphoto' cateogry --> extended description.
Not sure if my explanation is clear but I would appreciate any comments. By the way, our current work-around to display the variations is a product-specif html template where we hard-code the feature pics. Each feature pic is then linked to the extended product page. So the path is homepage --> productthumbnail --> hard-coded html template --> extended description. Neeless to say this is driving us crazy.
|
|
|
|
Topic |
|