Welcome, Guest ( Customer Panel | Login )




 All Forums
 VPCart Forum
 Customization
 Extended Image Code Contribution
 New Topic  Reply to Topic
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

rrold1
Starting Member

48 Posts

Posted - January 02 2004 :  12:31:57  Show Profile  Reply with Quote

I have set up a sub to display a " no image available " image in the extended descriptions if the "Extended Image" field is empty in the products database. This makes for a much more professional display if you don't have an image for a product and saves time against manually adding a no image file if you use one.

I am not an asp "expert" so if you see a problem or improvement, please post it!
It seems to work fine for me.


*** Be sure to backup your files before adding the code below! ****




Add at bottom of "Select Case" group around line 380:
'*******************Begin New Extended Image Case

Case "ADD_EXTENDEDIMAGEYESNO"
Handle_extendedyesnoimage value, parsearray
rc=0

'*******************End New Extended Image Case

Add to bottom of ShopFileio.asp:

'*******************Begin New Extended Image Sub

Sub Handle_extendedyesnoimage (ivalue, parsearray)

dim fieldvalue
dim rc
Dim Id, fieldname,fieldtype,extendedimage


fieldname="EXTENDEDIMAGE"
fieldvalue=""
FindInDatabase fieldname, fieldvalue, fieldtype ,rc,parsearray
if fieldvalue<>"" then
extendedimage= fieldvalue
response.write extendedimage
else
response.write "pathtoyournoimagefile.gif"
end if
end sub
'*******************End New Extended Image Sub

In your extended description file (tmp_product.htm), add the following where you want your extended image:

<img src="
[ADD_EXTENDEDIMAGEYESNO]"


I hope it works well for you!

Steve



MiniMe
Starting Member

24 Posts

Posted - January 03 2004 :  15:03:42  Show Profile  Reply with Quote
Looks like a good idea. Thanks for sharing! This may be a dumb question but I was just wondering in which file to include the first set of code. It says to include it "at bottom of 'Select Case' group around line 380" but I'm not sure which asp file.

Thanks again.
Go to Top of Page

rrold1
Starting Member

48 Posts

Posted - January 07 2004 :  13:01:56  Show Profile  Reply with Quote
Look in shopfileio.asp

Good luck!

Go to Top of Page

gene
Starting Member

10 Posts

Posted - January 13 2004 :  11:02:59  Show Profile  Reply with Quote
This is great Steve. Thank you.
Question: What if the field is not null but the image is does not exist?
Can this code be modified?
Thanks!
Gene

Go to Top of Page

dragon_tat
Starting Member

USA
17 Posts

Posted - January 19 2004 :  16:56:31  Show Profile  Reply with Quote
I have been unable to get this to function properly. What I recieve is the pathname of the image for both the extendedimage and the replacement. I'm working on it though...

Go to Top of Page

siraj
VP-CART New User

USA
194 Posts

Posted - January 30 2004 :  15:14:12  Show Profile  Visit siraj's Homepage  Reply with Quote
Hi dragon_tat,
Did yo get this one working!!!!
SJ.

[email protected]
Go to Top of Page

jonmadrid
VP-CART New User

USA
192 Posts

Posted - January 31 2004 :  07:57:09  Show Profile  Visit jonmadrid's Homepage  Reply with Quote
Hi All,

I don't know why this is but in order to get this to work, you need to have the [ADD_EXTENDEDIMAGEYESNO] on a second line for the image. It looks like thats what rrold1 hinted at in the way he had the code sample formatted but it may not have been clear that that needed to be done in order for it to work. I tried the code and got the same problem mentioned below (image src string + image shwoing up on page). So, I just put the [ADD_EXTENDEDIMAGEYESNO] on the second line in the template file and it worked just fine.

So you can see what I mean, the code would look like this:

*******
<img border="0" src="
[ADD_EXTENDEDIMAGEYESNO]">
*******

Hope that helps.

All the best,

Jon Madrid
--------------------
Madrid Communications
Web Design, Development, and Hosting
www.madridcom.com
Go to Top of Page

jonmadrid
VP-CART New User

USA
192 Posts

Posted - January 31 2004 :  08:09:43  Show Profile  Visit jonmadrid's Homepage  Reply with Quote
Hi All,

In answer to gene's question about what to do if the file doesn't exist, I modified to the code to handle that. I just added some extra logic in to see if the file exists or not. If it does, it shows the image; if it doesn't exist it will show the 'no image' image. I tested it a few times and it worked like a charm. Hope it helps you out.

Just replace the following code that was originally supposed to go at the bottom of the shopfileio.asp file with this code:

*******
Sub Handle_extendedyesnoimage (ivalue, parsearray)

dim fieldvalue
dim rc
Dim Id
Dim FieldName
Dim FieldType
Dim ExtendedImage
Dim FSO
Dim strNoImageFile

strNoImageFile = "pathtonoimagefile" 'Image to display when no image found.
FieldName ="EXTENDEDIMAGE"
FieldValue =""

'Get extended image value:
FindInDatabase fieldname, fieldvalue, fieldtype ,rc,parsearray

'If we have something to work with:
if FieldValue <>"" then

'See if the file the image string points to is there or not:
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
If FSO.fileExists(Server.Mappath(FieldValue)) then
'File exists:
ExtendedImage= FieldValue
response.write ExtendedImage
else
'File Does not exits:
response.write strNoImageFile
end if
'If no image to work with at all, just show 'no image' image:
Else
response.write strNoImageFile
End If
End Sub
*******

And away you go!... Enjoy!

All the best,

Jon Madrid
--------------------
Madrid Communications
Web Design, Development, and Hosting
www.madridcom.com

Edited by - jonmadrid on January 31 2004 08:13:55
Go to Top of Page

[email protected]
Starting Member

USA
44 Posts

Posted - February 01 2004 :  17:01:42  Show Profile  Visit johnrobinson@grahamcrackers.com's Homepage  Reply with Quote
I keep getting the following error:


Microsoft VBScript runtime error '800a01f4'

Variable is undefined: 'parsearray'

shopfileio.asp, line 383

Is this because I'm running VP-ASP 4.5 w/ MYSQL on a UNIX as apposed to ACCESS like most everyone else?

Any tips would be appreciated. This would be a nice little fix.

--John Robinson
www.grahamcrackers.com
Go to Top of Page

jonmadrid
VP-CART New User

USA
192 Posts

Posted - February 02 2004 :  08:20:56  Show Profile  Visit jonmadrid's Homepage  Reply with Quote
John R,

That error is not due to MySQL vs. Access... its giving you the error because a variable on the page has not been Dimmensioned (a.k.a. 'dim' or defined). This is a shot in the dark but you may want to try adding this line into the code at line 382 in shopfileio.asp (just after the line that reads: dim tokenformat):

*******
dim paresarray
*******

All that does is defines the variable for use. Try that and see if it solves your problems. Did you make any other changes to that shopfileio.asp file? If this doesnt fix your problem, you may want to post the code around those lines on here so we can have a look.

Hope that helps.

All the best,

Jon Madrid
--------------------
Madrid Communications
Web Design, Development, and Hosting
www.madridcom.com
Go to Top of Page

jonmadrid
VP-CART New User

USA
192 Posts

Posted - February 02 2004 :  08:32:39  Show Profile  Visit jonmadrid's Homepage  Reply with Quote
Hi All,

I just wanted to add a little note that the variation of the code I posted here that detects if the file exists or not uses the File System Object (FSO), which is intended for the Microsoft platform. It may or may not work on other platforms, depending on wether or not it is supported by the OS you're using. I just wanted to put that out there so people using something other than a Microsoft OS will be aware.

If it turns out that it doesn't work on your system, you can always just take that little bit of file sniffing code out and still have the basic function (whether image has been specified or not) available.

Good luck!

All the best,

Jon Madrid
--------------------
Madrid Communications
Web Design, Development, and Hosting
www.madridcom.com
Go to Top of Page

[email protected]
Starting Member

USA
44 Posts

Posted - February 02 2004 :  10:09:07  Show Profile  Visit johnrobinson@grahamcrackers.com's Homepage  Reply with Quote
Here's where I posted the code(line 383) in shopfileio.asp:
******
Case "SUB"
Handle_Product ucase(tokenformat)
rc=0
Case "ADD_EXTENDEDIMAGEYESNO"
Handle_extendedyesnoimage value, parsearray
rc=0
end select
end sub

Sub DoSpecialFormating (value, tokenformat)
If tokenformat="" then exit sub
dim strprice
******
I tried adding dim parsearray exactly where you asked to no avail (still get same error)
I also added the 2nd part of the code at line 907

******
CloseRecordset tmpRS
Shopclosedatabase dbc
end sub
Sub Handle_extendedyesnoimage (ivalue, parsearray)

dim fieldvalue
dim rc
Dim Id
Dim FieldName
Dim FieldType
Dim ExtendedImage
Dim FSO
Dim strNoImageFile

strNoImageFile = "http://www.grahamcrackers.com/images/85.jpg" 'Image to display when no image found.
FieldName ="EXTENDEDIMAGE"
FieldValue =""

'Get extended image value:
FindInDatabase fieldname, fieldvalue, fieldtype ,rc,parsearray

'If we have something to work with:
if FieldValue <>"" then

'See if the file the image string points to is there or not:
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
If FSO.fileExists(Server.Mappath(FieldValue)) then
'File exists:
ExtendedImage= FieldValue
response.write ExtendedImage
else
'File Does not exits:
response.write strNoImageFile
end if
'If no image to work with at all, just show 'no image' image:
Else
response.write strNoImageFile
End If
End Sub
'
Function HandleCustomerPrice (iprice)
dim discount, categoryid, ioprice, newprice
newprice=iprice
catalogid=templaterS("catalogid")
categoryid=templateRS("ccategory")
ShopCustomerPrices templateRS, catalogid, categoryid, iprice, newprice,discount
HandleCustomerprice=shopformatcurrency(newprice,getconfig("xdecimalpoint"))
end function
%>
******
I can not post it at the very end of shopfileio.asp as it won't take there either.

Anyone see anything I've done wrong above? I've retried in multiple places and ways to no avail. I always get that same error.


thanks!
--John Robinson
www.grahamcrackers.com
Go to Top of Page

jonmadrid
VP-CART New User

USA
192 Posts

Posted - February 02 2004 :  10:37:03  Show Profile  Visit jonmadrid's Homepage  Reply with Quote
John R,

What version of the cart are you using? I have a feeling this is related to that.

All the best,

Jon Madrid
--------------------
Madrid Communications
Web Design, Development, and Hosting
www.madridcom.com
Go to Top of Page

[email protected]
Starting Member

USA
44 Posts

Posted - February 02 2004 :  11:22:34  Show Profile  Visit johnrobinson@grahamcrackers.com's Homepage  Reply with Quote
HI Jon -
I'm running version 4.5.

--John

--John Robinson
http://www.GrahamCrackers.com
Go to Top of Page

jonmadrid
VP-CART New User

USA
192 Posts

Posted - February 02 2004 :  11:27:11  Show Profile  Visit jonmadrid's Homepage  Reply with Quote
John R,

That may be why. If you send me the entire shopfileio.asp file I can have a look at it and try to make it work for that version. I may be off base though and it may not be version related at all. Either way, if you send me the file I can have a look at it and see. Send it over if you like: [email protected]

All the best,

Jon Madrid
--------------------
Madrid Communications
Web Design, Development, and Hosting
www.madridcom.com
Go to Top of Page

dragon_tat
Starting Member

USA
17 Posts

Posted - February 04 2004 :  06:26:36  Show Profile  Reply with Quote
Thanks Jon for the contribution. I also had the [ADD_EXTENDEDIMAGEYESNO] on the same line as the source and was unable to get that to work properly.

Go to Top of Page
Page: of 2
Previous Topic Topic Next Topic  
Next Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000
0 Item(s)
$0.00