Guest Posted October 10, 2002 Share Posted October 10, 2002 This module will allow you to display a truncated version of your product description in the new products box - The description is truncated at a predefined number of characters (defined in the Admin panel) and a trailing ellipsis (...) added. This is a addon to the Short Description in Product Listing posted by John Poynton Changes are in general.php added this code //// // Return a product's description // TABLES: products description function tep_get_products_description($product_id) { global $languages_id; $product_query = tep_db_query("select products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $product_id . "' and language_id = '" . $languages_id . "'"); $product_description = tep_db_fetch_array($product_query); return $product_description['products_description']; } In new_products.php added this at line 30 $new_products['products_description'] = tep_get_products_description($new_products['products_id']); and this at line 33 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><b><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a></b><br>' . osc_trunc_string(strip_tags($new_products['products_description'], '<a><b><em><font><i><s><span><strong><sub><sup><u>'), PRODUCT_LIST_DESCRIPTION_LENGTH) . '<br><b>' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']).'</b>')); It will work witout Short Description in Product Listing posted by John Poynton but you will not be able to control the lenght of the description Quote Link to comment Share on other sites More sharing options...
CC Posted October 10, 2002 Share Posted October 10, 2002 Kenny You da man! :biggrin: I have said it before but i will say it again... I love your sites!! Keep it up mate! CC. Quote Link to comment Share on other sites More sharing options...
Guest Posted October 10, 2002 Share Posted October 10, 2002 Looks great, nice work :) not working with my 'older' snapshot (july) tho, damn :/ osc_trunc_string() is not defined , i assume that must be a new function in newer snapshots, anyone got any ideas? ;) I have short desc. in product listing v1.1 installed and working a treat, i assume this mod is based on the 1.2. I may have a stab at making it work, any pointer greatly appreciated :) Thanks again, looks nice, great sites too. Matt www.consoleplus.co.uk Quote Link to comment Share on other sites More sharing options...
Guest Posted October 10, 2002 Share Posted October 10, 2002 on line 33 in new products try removeing this osc_trunc_string(strip_tags( Quote Link to comment Share on other sites More sharing options...
Guest Posted October 10, 2002 Share Posted October 10, 2002 and if that dont work remove this aswell in line 33 , '<a><b><em><font><i><s><span><strong><sub><sup><u>' Quote Link to comment Share on other sites More sharing options...
Guest Posted October 10, 2002 Share Posted October 10, 2002 Thanks, that certianly helped, but the problem is now that i get the whole product description with each product, not a short truncated description with the ... 's , here is my line 33 from new products: 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><b><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a></b><br>' . $new_products['products_description'], '<a><b><em><font><i><s><span><strong><sub><sup><u>', PRODUCT_LIST_DESCRIPTION_LENGTH . '<br><b>' . $currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']).'</b>')); im assuming PRODUCT_LIST_DESCRIPTION_LENGTH has something to do with this, i have tried manually defining that to a set value (though my syntax may well be incorrect), i do not get any warnings saying it is not defined. Thanks again for all your help! Quote Link to comment Share on other sites More sharing options...
mattice Posted October 10, 2002 Share Posted October 10, 2002 check out www.php.net/substr basically you could do : $truncated = substr($new_products['products_description'], 0, PRODUCT_LIST_DESCRIPTION_LENGTH ); which will give you from 0 (start) to PRODUCT_LIST_DESCRIPTION_LENGTH. Quote "Politics is the art of preventing people from taking part in affairs which properly concern them" Link to comment Share on other sites More sharing options...
Guest Posted October 10, 2002 Share Posted October 10, 2002 I'm gonna have to crack out my 'beginning php4' book i think :) I understand what you say, i assume you are defining a variable ($truncated) which will have a value of 0 - product_list_description_length - please bear in mind i am not a programmer, in any way shape or form :) What i cannot do then is incoroprate that into the code to determine the length of the product listing :/ As I say i think i beeter get my head in the book for a few weeks :) Thanks again for taking the time to help tho. Matt www.consoleplus.co.uk Quote Link to comment Share on other sites More sharing options...
CC Posted October 10, 2002 Share Posted October 10, 2002 Kenny I am trying to get this to work with the featured products addon. But i am unable to get it to integrate. Featured products is based on new_products.php so it should fit nicely. Could you give me some pointers on how to get your mod to integrate with this file? I have been searching for ages for your kind of mod, so I cant afford to let it slip away. Thanks buddy, here is the code for featured_products.php: <?php /* osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2002 osCommerce Released under the GNU General Public License Featured Products Listing Module */ ?> <table border="0" width="100%" cellspacing="0" cellpadding="2"> <?php if (sizeof($featured_products_array) == '0') { ?> <tr> <td class="main"><?php echo TEXT_NO_FEATURED_PRODUCTS; ?></td> </tr> <?php } else { for($i=0; $i<sizeof($featured_products_array); $i++) { if ($featured_products_array[$i]['specials_price']) { $products_price = '<s>' . $currencies->display_price($featured_products_array[$i]['price'], tep_get_tax_rate($featured_products_array[$i]['tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($featured_products_array[$i]['specials_price'], tep_get_tax_rate($featured_products_array[$i]['tax_class_id'])) . '</span>'; } else { $products_price = $currencies->display_price($featured_products_array[$i]['price'], tep_get_tax_rate($featured_products_array[$i]['tax_class_id'])); } ?> <tr> <td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products_array[$i]['id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . $featured_products_array[$i]['image'], $featured_products_array[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td> <td valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products_array[$i]['id'], 'NONSSL') . '"><b><u>' . $featured_products_array[$i]['name'] . '</u></b></a><br>' . TEXT_DATE_ADDED . ' ' . $featured_products_array[$i]['date_added'] . '<br>' . TEXT_MANUFACTURER . ' ' . $featured_products_array[$i]['manufacturer'] . '<br><br>' . TEXT_PRICE . ' ' . $products_price; ?></td> <td align="right" valign="middle" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_FEATURED_PRODUCTS, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $featured_products_array[$i]['id'], 'NONSSL') . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a>'; ?></td> </tr> <?php if (($i+1) != sizeof($featured_products_array)) { ?> <tr> <td colspan="3" class="main"> </td> </tr> <?php } } } ?> </table> Hope you can help.... CC Quote Link to comment Share on other sites More sharing options...
Guest Posted October 10, 2002 Share Posted October 10, 2002 This is a version of featured.php from Featured Products V1.2 located in the modules file you will still need to place the code in general.php <?php /* osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2002 osCommerce Released under the GNU General Public License Featured Products V1.1 Displays a list of featured products, selected from admin For use as an Infobox instead of the "New Products" Infobox */ ?> <!-- featured_products //--> <?php if(FEATURED_PRODUCTS_DISPLAY == true) { $featured_products_category_id = $new_products_category_id; $cat_name_query = tep_db_query("select categories_name from categories_description where categories_id = '" . $featured_products_category_id . "' limit 1"); $cat_name_fetch = tep_db_fetch_array($cat_name_query); $cat_name = $cat_name_fetch['categories_name']; $info_box_contents = array(); if ( (!isset($featured_products_category_id)) || ($featured_products_category_id == '0') ) { $info_box_contents[] = array('align' => 'left', 'text' => '<a href="' . tep_href_link(FILENAME_FEATURED_PRODUCTS) . '">' . TABLE_HEADING_FEATURED_PRODUCTS . '</a>'); $featured_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_status = '1' and f.status = '1' order by rand() DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS); } else { $info_box_contents[] = array('align' => 'left', 'text' => sprintf(TABLE_HEADING_FEATURED_PRODUCTS_CATEGORY, $cat_name)); $featured_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $featured_products_category_id . "' and p.products_status = '1' and f.status = '1' order by rand() DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS); } $row = 0; $col = 0; $num = 0; while ($featured_products = tep_db_fetch_array($featured_products_query)) { $num ++; if ($num == 1) { new contentBoxHeading($info_box_contents); } $featured_products['products_name'] = tep_get_products_name($featured_products['products_id']); $featured_products['products_description'] = tep_get_products_description($featured_products['products_id']); if($featured_products['specstat']) { $info_box_contents[$row][$col] = array('align' => 'center', 'params' => 'class="smallText" width="33%" valign="top"', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] . '</a><br>' . osc_trunc_string(strip_tags($featured_products['products_description'], '<a><b><em><font><i><s><span><strong><sub><sup><u>'), PRODUCT_LIST_DESCRIPTION_LENGTH) . '<br><s>' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price($featured_products['specials_new_products_price'], tep_get_tax_rate($featured_products['products_tax_class_id'])) . '</span>'); } else { $info_box_contents[$row][$col] = array('align' => 'center', 'params' => 'class="smallText" width="33%" valign="top"', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $featured_products['products_image'], $featured_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $featured_products['products_id']) . '">' . $featured_products['products_name'] . '</a><br>' . osc_trunc_string(strip_tags($featured_products['products_description'], '<a><b><em><font><i><s><span><strong><sub><sup><u>'), PRODUCT_LIST_DESCRIPTION_LENGTH) . '<br>' . $currencies->display_price($featured_products['products_price'], tep_get_tax_rate($featured_products['products_tax_class_id']))); } $col ++; if ($col > 2) { $col = 0; $row ++; } } if($num) { new contentBox($info_box_contents); } } else // If it's disabled, then include the original New Products box { include (DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); } ?> <!-- featured_products_eof //--> Quote Link to comment Share on other sites More sharing options...
Guest Posted October 10, 2002 Share Posted October 10, 2002 Please can anyone show me how to add the product description (preferably the in full) to this: <!-- show_random //--> <tr> <td> <?php if ($HTTP_GET_VARS['cPath']) { if ($random_product = tep_random_select("select p.products_id, p.products_mediumimage, p.products_tax_class_id, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where products_status='1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and (c.categories_id = '" . $current_category_id . "' OR c.parent_id = '" . $current_category_id . "') order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) { $random_product['products_name'] = tep_get_products_name($random_product['products_id']); $random_product['specials_new_products_price'] = tep_get_products_special_price($random_product['products_id']); $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', 'text' => Spotlight ); new infoBoxHeading($info_box_contents, false, false); if ($random_product['specials_new_products_price']) { $rprod_price = '<s>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</s><br>'; $rprod_price .= '<span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>'; } else { $rprod_price = $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])); } $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_mediumimage'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id'], 'NONSSL') . '">' . $random_product['products_name'] . '</a><br>' . $rprod_price ); new infoBox($info_box_contents); } } else { if ($random_product = tep_random_select("select products_id, products_mediumimage, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status='1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) { $random_product['products_name'] = tep_get_products_name($random_product['products_id']); $random_product['specials_new_products_price'] = tep_get_products_special_price($random_product['products_id']); $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', 'text' => Spotlight ); new infoBoxHeading($info_box_contents, false, false); if ($random_product['specials_new_products_price']) { $rprod_price = '<s>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</s><br>'; $rprod_price .= '<span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>'; } else { $rprod_price = $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])); } $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_mediumimage'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id'], 'NONSSL') . '">' . $random_product['products_name'] . '</a><br>' . $rprod_price ); new infoBox($info_box_contents); } } ?> </td> </tr> <!-- show_random_eof //--> Thanks Quote Link to comment Share on other sites More sharing options...
Guest Posted October 10, 2002 Share Posted October 10, 2002 This should do the trick <!-- show_random //--> <tr> <td> <?php if ($HTTP_GET_VARS['cPath']) { if ($random_product = tep_random_select("select p.products_id, p.products_mediumimage, p.products_tax_class_id, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where products_status='1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and (c.categories_id = '" . $current_category_id . "' OR c.parent_id = '" . $current_category_id . "') order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) { $random_product['products_name'] = tep_get_products_name($random_product['products_id']); $random_product['specials_new_products_price'] = tep_get_products_special_price($random_product['products_id']); $random_product['products_description'] = tep_get_products_description($random_product['products_id']); $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', 'text' => Spotlight ); new infoBoxHeading($info_box_contents, false, false); if ($random_product['specials_new_products_price']) { $rprod_price = '<s>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</s><br>'; $rprod_price .= '<span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>'; } else { $rprod_price = $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])); } $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_mediumimage'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id'], 'NONSSL') . '">' . $random_product['products_name'] . '</a><br>' . osc_trunc_string(strip_tags($random_product['products_description'], '<a><b><em><font><i><s><span><strong><sub><sup><u>'), PRODUCT_LIST_DESCRIPTION_LENGTH) . '<br>' . $rprod_price ); new infoBox($info_box_contents); } } else { if ($random_product = tep_random_select("select products_id, products_mediumimage, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status='1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) { $random_product['products_name'] = tep_get_products_name($random_product['products_id']); $random_product['specials_new_products_price'] = tep_get_products_special_price($random_product['products_id']); $random_product['products_description'] = tep_get_products_description($random_product['products_id']); $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', 'text' => Spotlight ); new infoBoxHeading($info_box_contents, false, false); if ($random_product['specials_new_products_price']) { $rprod_price = '<s>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</s><br>'; $rprod_price .= '<span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>'; } else { $rprod_price = $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])); } $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_mediumimage'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id'], 'NONSSL') . '">' . $random_product['products_name'] . '</a><br>' . osc_trunc_string(strip_tags($random_product['products_description'], '<a><b><em><font><i><s><span><strong><sub><sup><u>'), PRODUCT_LIST_DESCRIPTION_LENGTH) . '<br>' . $rprod_price ); new infoBox($info_box_contents); } } ?> </td> </tr> <!-- show_random_eof //--> Quote Link to comment Share on other sites More sharing options...
Guest Posted October 10, 2002 Share Posted October 10, 2002 Oh man thanks so much!! :thumbsup: BTW, anyway it can shaw all the description? Quote Link to comment Share on other sites More sharing options...
Guest Posted October 10, 2002 Share Posted October 10, 2002 do you want it to show the whole description :?: Quote Link to comment Share on other sites More sharing options...
Guest Posted October 10, 2002 Share Posted October 10, 2002 Yes Quote Link to comment Share on other sites More sharing options...
Guest Posted October 10, 2002 Share Posted October 10, 2002 Preferably with the picture to the right and description to the left if possible. Quote Link to comment Share on other sites More sharing options...
Guest Posted October 10, 2002 Share Posted October 10, 2002 if you want the whole description use this and dont forget to add the extra code to genral.php <!-- show_random //--> <tr> <td> <?php if ($HTTP_GET_VARS['cPath']) { if ($random_product = tep_random_select("select p.products_id, p.products_mediumimage, p.products_tax_class_id, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where products_status='1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and (c.categories_id = '" . $current_category_id . "' OR c.parent_id = '" . $current_category_id . "') order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) { $random_product['products_name'] = tep_get_products_name($random_product['products_id']); $random_product['specials_new_products_price'] = tep_get_products_special_price($random_product['products_id']); $random_product['products_description'] = tep_get_products_description($random_product['products_id']); $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', 'text' => Spotlight ); new infoBoxHeading($info_box_contents, false, false); if ($random_product['specials_new_products_price']) { $rprod_price = '<s>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</s><br>'; $rprod_price .= '<span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>'; } else { $rprod_price = $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])); } $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_mediumimage'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id'], 'NONSSL') . '">' . $random_product['products_name'] . '</a><br>' . $random_product['products_description'] . '<br>' . $rprod_price ); new infoBox($info_box_contents); } } else { if ($random_product = tep_random_select("select products_id, products_mediumimage, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status='1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) { $random_product['products_name'] = tep_get_products_name($random_product['products_id']); $random_product['specials_new_products_price'] = tep_get_products_special_price($random_product['products_id']); $random_product['products_description'] = tep_get_products_description($random_product['products_id']); $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', 'text' => Spotlight ); new infoBoxHeading($info_box_contents, false, false); if ($random_product['specials_new_products_price']) { $rprod_price = '<s>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</s><br>'; $rprod_price .= '<span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>'; } else { $rprod_price = $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])); } $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_mediumimage'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id'], 'NONSSL') . '">' . $random_product['products_name'] . '</a><br>' . $random_product['products_description'] . '<br>' . $rprod_price ); new infoBox($info_box_contents); } } ?> </td> </tr> <!-- show_random_eof //--> Quote Link to comment Share on other sites More sharing options...
Guest Posted October 10, 2002 Share Posted October 10, 2002 if you need to change it just add the needed html codes on this part $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_mediumimage'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id'], 'NONSSL') . '">' . $random_product['products_name'] . '</a><br>' . $random_product['products_description'] . '<br>' . $rprod_price Quote Link to comment Share on other sites More sharing options...
Guest Posted October 10, 2002 Share Posted October 10, 2002 I dunno what to say but thanks so much. :D Quote Link to comment Share on other sites More sharing options...
Guest Posted October 11, 2002 Share Posted October 11, 2002 been gettin nuthin but errors: Dunno how to go about it: $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', <table border="0" cellspacing="0" cellpadding="0"> <tr> <td height="135"> <div align="right"> <table border="0" align="right" cellpadding="2" cellspacing="0"> <tr> <td valign= "_top" height="45" align="center" class="smallText">'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_mediumimage'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) '); . '</a><br> </td> </tr> </table> <div align="left">'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id'], 'NONSSL') . '">' . $random_product['products_name'] . '</a><br> ' . $random_product['products_description'] . '<br> ' . $rprod_price );</div> </div></td> </tr> </table> Any ideas? Quote Link to comment Share on other sites More sharing options...
Guest Posted October 11, 2002 Share Posted October 11, 2002 I tried this but still nuthin $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', 'text' => '<td><table border="0" align="right" cellpadding="2" cellspacing="0"><tr><td valign="top" height="25" align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_mediumimage'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td></tr></table><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id'], 'NONSSL') . '">' . $random_product['products_name'] . '</a><br>' . $random_product['products_description'] . '<br>' . $rprod_price </td> ); Parse error: parse error, unexpected '/' on line 29 Any ideas? Quote Link to comment Share on other sites More sharing options...
Paul_C Posted October 11, 2002 Share Posted October 11, 2002 osc_trunc_string() is not defined , i assume that must be a new function in newer snapshots, anyone got any ideas? ;) I have short desc. in product listing v1.1 installed and working a treat, i assume this mod is based on the 1.2. osc_trunc_string is from Description in Product Listing v.2. The function truncates without breaking a word and adds the ellipses if appropriate. If you don't already have it just add the following to catalog/includes/functions/general.php function osc_trunc_string($str="",$len=150,$more=1) { if ($str=="") return $str; if (is_array($str)) return $str; $str = trim($str); // if it's les than the size given, then return it if (strlen($str) <= $len) return $str; // else get that size of text $str = substr($str,0,$len); // backtrack to the end of a word if ($str != "") { // check to see if there are any spaces left if (!substr_count($str," ")) { if ($more) $str .= "..."; return $str; } // backtrack while(strlen($str) && ($str[strlen($str)-1] != " ")) { $str = substr($str,0,-1); } $str = substr($str,0,-1); if ($more) $str .= "..."; } return $str; } Quote "It's a damn poor mind that can only think of one way to spell a word." -- Andrew Jackson Link to comment Share on other sites More sharing options...
Guest Posted October 11, 2002 Share Posted October 11, 2002 Illicious I think this is what your looking for you can see a demo here the Featured Products table http://www.pcbuzzard.de/allprods.php <p> <table cellpadding="3" cellspacing="0" border="0"> <tr> <td class="main"><b>Featured Products :</b></td> </tr> </table> <table bgcolor="#0033FF" cellpadding="1" cellspacing="0" border="0" width="100%"> <tr> <td class="text"> <table width="100%" bgcolor="#FFF8E9" cellpadding="5" cellspacing="0" border="0"> <tr> <td class="text"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td class="text"> <table border="0" width="100%" cellspacing="0" cellpadding="0" class="infoBox"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="4" class="infoBoxContents"> <tr> <?php if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status='1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) { $random_product['products_name'] = tep_get_products_name($random_product['products_id']); $random_product['specials_new_products_price'] = tep_get_products_special_price($random_product['products_id']); $random_product['products_description'] = tep_get_products_description($random_product['products_id']); } if ($random_product['specials_new_products_price']) { $whats_new_price = '<s>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</s><br>'; $whats_new_price .= '<span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>'; } else { $whats_new_price = $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])); } ?> <td align="center" class="main" width="33%" valign="top"><?php echo'<a href="' .tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td> <td align="left" class="main" width="33%" valign="top"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id'], 'NONSSL') . '"><b>' . $random_product['products_name'] . '</b></a><br><b><font color="#CC0000">' . $whats_new_price . '</font></b><br>' . osc_trunc_string(strip_tags($random_product['products_description'], '<a><b><em><font><i><s><span><strong><sub><sup><u>'), PRODUCT_LIST_DESCRIPTION_LENGTH) . '<br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '" alt="More info...">More info...</a></p>'; ?></td></tr><p> <tr> <?php if ($random_product = tep_random_select("select products_id, products_image, products_tax_class_id, products_price from " . TABLE_PRODUCTS . " where products_status='1' order by products_date_added desc limit " . MAX_RANDOM_SELECT_NEW)) { $random_product['products_name'] = tep_get_products_name($random_product['products_id']); $random_product['specials_new_products_price'] = tep_get_products_special_price($random_product['products_id']); $random_product['products_description'] = tep_get_products_description($random_product['products_id']); } if ($random_product['specials_new_products_price']) { $whats_new_price = '<s>' . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</s><br>'; $whats_new_price .= '<span class="productSpecialPrice">' . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '</span>'; } else { $whats_new_price = $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])); } ?> <td align="center" class="main" width="33%" valign="top"><?php echo'<a href="' .tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td> <td align="left" class="main" width="33%" valign="top"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id'], 'NONSSL') . '"><b>' . $random_product['products_name'] . '</b></a><br><b><font color="#CC0000">' . $whats_new_price . '</font></b><br>' . osc_trunc_string(strip_tags($random_product['products_description'], '<a><b><em><font><i><s><span><strong><sub><sup><u>'), PRODUCT_LIST_DESCRIPTION_LENGTH) . '<br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '" alt="More info...">More info...</a></p>'; ?></td> </table> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> Quote Link to comment Share on other sites More sharing options...
Guest Posted October 11, 2002 Share Posted October 11, 2002 I almost have it working: 'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $random_product['products_mediumimage'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id'], 'NONSSL') . '">' . $random_product['products_name'] . '</a><br>' . $random_product['products_description'] . '<br>' . $rprod_price ); [quote] Thanks for the code and when i have this done all prolly start work on a modified version of featured products aswell.[/quote] Quote Link to comment Share on other sites More sharing options...
Jan0815 Posted October 11, 2002 Share Posted October 11, 2002 Could we please stop abusing the forum for file exchange? ;-) Short code snippets are fine, but complete files cost an awful lot of traffic. Is that really needed? Additionally this thread looks really cluttered. May I kindly remind of the forum rules: The forum is for information exchange only. Commercial advertising is not allowed. Any features mentioned in the forums must be freely available under the GPL license and freely downloadable at the Contributions section on the osCommerce support site. So if this code is working - make it a contribution. If it is a Work In Progress - put some zip file on your own server and post the link here. Once it is finsihed - contribution. Don't get me wrong, this thread is very productive and interesting - keep up the good work. I simply ask you to change the methods used. Quote You can't have everything. That's why trains have difficulty crossing oceans, and hippos did not adapt to fly. -- from the OpenBSD mailinglist. 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.