gevans Posted June 30, 2003 Posted June 30, 2003 I've added a field to my products table called products_pdf (This is so I can attach a pdf datasheet to a product). To do this I basically copied all the code for adding an image to a product but changed every instance of image to pdf. It works pretty well except for the instance when I update or add a product and don't supply a pdf for it. In this case 'Array' gets inserted into the products_pdf field for that product. The problem this causes is when a customer loads the product_info.php page and 'Array' is the contents of the products_pdf field. When this happens I get a link to www.mystore.com/pdf/Array instead of no link beign displayed. This is the code I use to insert the link for the pdf datasheet: <?php if ($product_info_values['products_pdf'] != '') echo '<br><a href="' . tep_href_link(DIR_WS_PDF . $pdf) . '">Product Datasheet</a> <img src="images/pdf.gif">'; ?> I've also tried adding a pdf using the mimage and bimage code structure which doesn't give me this problem however this method seems to forget the pdf's filename whenever that product is updated. Can anybody point me in the right direction to fix this little annoyance? TIA
mdfst13 Posted June 30, 2003 Posted June 30, 2003 Have you tried <?php if ($product_info_values['products_pdf'] != 'Array') echo '<br><a href="' . tep_href_link(DIR_WS_PDF . $pdf) . '">Product Datasheet</a> <img src="images/pdf.gif">'; ?> instead? For debugging purposes, it wouldn't hurt to change the echo to echo '<-- "' . $product_info_values['products_pdf'] . '" //--><br><a href="' . tep_href_link(DIR_WS_PDF . $pdf) . '">Product Datasheet</a> <img src="images/pdf.gif">'; Note: you will have to View Source in your browser to see the results. Hth, Matt I love deadlines. I like the whooshing sound they make as they fly by. ---Douglas Adams
gevans Posted June 30, 2003 Author Posted June 30, 2003 Yes I have. All that will do is create an 'empty' link like: http://127.0.0.1/store/pdf/?osCsid=afd77aa...08365b577116a48 if there is nothing in the products_pdf field. Now if there was a bit of code that could do both if ($product_info_values['products_pdf'] !='Array' and !='' then I could live with it. Thanks for the reply.
Guest Posted June 30, 2003 Posted June 30, 2003 if(($random != 0) && ($random2 == 1)) { blah blah } that will allow for two condition statements, unless I'm misunderstanding what you want to do this should work. I have about 8 on one if statement and had to move it to two separate if statements though because of php...so if it doesnt work, try a nested if statement.
gevans Posted July 2, 2003 Author Posted July 2, 2003 Yes that sounds like a good idea. I was also thinking I could just set the default for the db field to 'Array' and then use the following code if ($product_info_values['products_pdf'] != 'Array') But if anyone has other suggestions I'd appreciate them.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.