Pica Posted December 9, 2002 Share Posted December 9, 2002 I have been customizing OSC to my specific needs. I have more than 15.000 items to put in it. Most of these have a technote with detailed information (motherboards, processors, hard-drives...). For the time being I have replaced the "Click to enlarge" link below the product image to open a popup window with the specific "technote". I managed to have it displayed dynamicaly with the product's image, reference, description... My problem is when a product has NO technote... Seeing I use a INCLUDE line which adds a table with the specific technote, when there is none I have the product image, reference and description displayd correctly as well as the bottom disclaimer message... BUT in the middle I get this error message saying it didn't find the specific technote table-file. Is there a way to use a dummy or no-technote file included when it doesn't find a PHP file corresponding to the products reference? Thanks in advance. Paulo Quote Link to comment Share on other sites More sharing options...
Guest Posted December 10, 2002 Share Posted December 10, 2002 Just throw an If statement in to check if it exists... if not, put something else in. Quote Link to comment Share on other sites More sharing options...
Pica Posted December 10, 2002 Author Share Posted December 10, 2002 Thanks for that clue Jaryd... Care to be more specific ? It's just that I've been fighting with code in every way and must say am quite tired... Need some sleep, I guess. Thank you in advance. Quote Link to comment Share on other sites More sharing options...
Guest Posted December 10, 2002 Share Posted December 10, 2002 If (include(phpfile.php)) { include(phpfile.php); } else { include(otherfile.php); } Quote Link to comment Share on other sites More sharing options...
Pica Posted December 10, 2002 Author Share Posted December 10, 2002 Hummm... interesting !!! I just tried it and it worked ALMOST right !!! :? Here's how I put it in the code : If (include(DIR_WS_PROD_TECHNOTES . $products_values['products_name'] . '.php')) { include(DIR_WS_PROD_TECHNOTES . $products_values['products_name'] . '.php'); } else { include(DIR_WS_PROD_TECHNOTES . 'no_technote.php'); } When I select a product which has its own technote, I get the Popup specific technote correctly. When I select a product which has no technote, I get the Popup window with the product's name, picture, reference, description AND 1. an error message : Warning: Failed opening 'technotes/058Y034.php' for inclusion (include_path='.:/usr/local/php/lib/php') in /usr/local/httpdocs/catalog/popup_details.php on line 94 2. I also get the contents of the desired no_technote.php block, which is shown correctly. That is almost perfect for my needs. If you know what's wrong in the code above, I'm all ears... I don't know if this may be an interesting feature to others. Thanks once more. Paulo. Quote Link to comment Share on other sites More sharing options...
Pica Posted December 10, 2002 Author Share Posted December 10, 2002 BTW, in the code above, the file technotes/058Y034.php refers to the specific 058Y034 product which has no technote-file defined. Everything else is taken from the "products & co" tables. Paulo. Quote Link to comment Share on other sites More sharing options...
Guest Posted December 10, 2002 Share Posted December 10, 2002 If (include(DIR_WS_PROD_TECHNOTES . $products_values['products_name'] . '.php')) { include(DIR_WS_PROD_TECHNOTES . $products_values['products_name'] . '.php'); } else { include(DIR_WS_PROD_TECHNOTES . 'no_technote.php'); } Try taking out the DIR_WS_PROD_TECHNOTES . so it looks like this: If (include(DIR_WS_PROD_TECHNOTES . $products_values['products_name'] . '.php')) { include(DIR_WS_PROD_TECHNOTES . $products_values['products_name'] . '.php'); } else { include('no_technote.php'); } Quote Link to comment Share on other sites More sharing options...
Guest Posted December 10, 2002 Share Posted December 10, 2002 I may be interested in this feature if you get it working... Quote Link to comment Share on other sites More sharing options...
Pica Posted December 11, 2002 Author Share Posted December 11, 2002 HOURRA !!! :D After fighting around with some PHP code ( I am not even a novice on this) I finally got it working !!! I just needed something to check if the specific file exists... I use this in stead of the "Click To Enlarge" link. I created a copy of the initial popup file and called "popup_details.php". This file is build on different blocks of code/text (in this order) : 1. the common technote header for all technotes 2. the specific product image taken from the "products_image" 3. the specific product description taken from the "products_description" 4. the specific product reference taken from "products_name" 5. the specific products technote from a separate file 6. the common footer disclqimer message NB: in step "5." if the specific technote file does NOT exist, it picks a common empty technote. VOILA !!! Thanks for your hints on this matter. Paulo. 8) Quote Link to comment Share on other sites More sharing options...
Pica Posted December 11, 2002 Author Share Posted December 11, 2002 It's better when I do not forget to put the code in my message... doooo!!! :roll: Here it is : <?php if (file_exists (DIR_WS_PROD_TECHNOTES . $products_values['products_name'] . '.php')) { include (DIR_WS_PROD_TECHNOTES . $products_values['products_name'] . '.php'); } else { include(DIR_WS_PROD_TECHNOTES . 'no_technote.php');} ?> This is just the body of the popup_details.php which gets the technote block. Paulo. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.