xirrom Posted January 20, 2007 Share Posted January 20, 2007 How can I show a 'dummy' Image (No Image Available) for products that do not have an existing image available? I did a search in this osc forum and found another sollution but unfortunally the code did not exactly match with my code. Below is my code. I found it in the file Product_listing.php. (I assume this is the part that should be edited.) Is there anyone who wants to help me and tell/show me what to change or add in this code so that a 'dummy' picture will be shown when there is not a real image for that product available? This is a part of the code in my product_listing.php case 'PRODUCT_LIST_IMAGE': $lc_align = 'center'; if (isset($HTTP_GET_VARS['manufacturers_id'])) { $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; } else { $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> '; } break; Link to comment Share on other sites More sharing options...
bill110 Posted January 20, 2007 Share Posted January 20, 2007 You don't really have to edit code. Just have your own "no image available" image and when you add a product without an image use that one as the product image. My Contributions Stylesheet With Descriptions Glassy Grey Boxtops Our Products Meta Tags On The Fly Password Protect Admin "No matter where you go....There you are" - Buccaroo Bonsai Link to comment Share on other sites More sharing options...
xirrom Posted January 20, 2007 Author Share Posted January 20, 2007 I don't add products manually: its done automatically by an external script. Currently there are over 8000 products in the database. Approx. 25% does not have an image. For all those products that don't have an image, I need a sollution: the script should be modified to show a dummy image. A product listening looks like this: Link to comment Share on other sites More sharing options...
jonquil Posted January 20, 2007 Share Posted January 20, 2007 I understand your intent but I think you're going about it the long way with many pages of code to edit. You gave the code chunk for catalog/product_listing.php. This is the only area where your edit would function. Consider the product_info, products_new, etc. Give this a try: case 'PRODUCT_LIST_IMAGE': $lc_align = 'center'; if (isset($HTTP_GET_VARS['manufacturers_id'])) { $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; } else { $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> '; } else { $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . "notavail.gif", $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>?'; } break; Just upload a custom notavail.gif or whatever your dummy image is. Be sure to match your dummy filename in the last code chunk above. Again, this will only work for the Product Listing page unless you manually find and edit the code in a bunch of other pages. May I suggest that in your external script's image name field that you enter "notavail.gif" (or whatever) when no product image file name is available. This would accomplish the same thing as a manual edit of any product with a missing product image, and IMHO, this is a better way to accomplish what you want to achieve. jon It's all just ones and zeros.... Link to comment Share on other sites More sharing options...
♥bruyndoncx Posted January 20, 2007 Share Posted January 20, 2007 Everyone above makes valid points, but I can sympathise with you :) Even though I'm doing the coding and customizing for my loading scripts too, I've found it easier to adapt the listing pages to make sure that everything shows up nicely on the surface, without having to go and edit the products. So here goes ... As a first entry within your case statement, you'd want to add this line which basically adhoc sets a default image. if (!$listing['products_image']) $listing['products_image'] = 'nopicture.gif'; Basically, you can modify/adapt this one liner for each page where you want this quick fix. HTH KEEP CALM AND CARRY ON I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support). So if you are still here ? What are you waiting for ?! Find the most frequent unique errors to fix: grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt Link to comment Share on other sites More sharing options...
wheeloftime Posted January 21, 2007 Share Posted January 21, 2007 Everyone above makes valid points, but I can sympathise with you :) Even though I'm doing the coding and customizing for my loading scripts too, I've found it easier to adapt the listing pages to make sure that everything shows up nicely on the surface, without having to go and edit the products. So here goes ... As a first entry within your case statement, you'd want to add this line which basically adhoc sets a default image. if (!$listing['products_image']) $listing['products_image'] = 'nopicture.gif'; Basically, you can modify/adapt this one liner for each page where you want this quick fix. HTH Adding my 2cts. I would just make a slight alteration to my database. Go to the products tabel and edit the field products_image. With 'standard value' fill in 'no_image.gif' or something and from now on every new product will have that image for default. Run a one time query to find all existing products with no image attached and replace the empty field with again the value 'no_image.gif'. UPDATE `products` SET `products_image` = 'no_image.gif' WHERE `products_image` = '' You could also run this one query after each batch upload into osCommerce and keep it with that. Link to comment Share on other sites More sharing options...
xirrom Posted January 26, 2007 Author Share Posted January 26, 2007 Hello 2-All, Thanks for your help! The simplest solution was to rename the NULL in the database to no_image.gif and refill all NULLS by updating. That works perfectly (offcourse...) but you just need to come up with such easy sollution... Well, this is a sullution what used to refer as 'KISS'. Link to comment Share on other sites More sharing options...
♥bruyndoncx Posted January 26, 2007 Share Posted January 26, 2007 just make sure that when you use easypopulate to load your database that you don't supply an empty string and effectively remove the database default value ... if it happens, you've been warned :) KEEP CALM AND CARRY ON I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support). So if you are still here ? What are you waiting for ?! Find the most frequent unique errors to fix: grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.