Guest Posted October 7, 2008 Share Posted October 7, 2008 Is there anyway to only show a number of character in product`s name and only show the complete name in the product info page? Like in the main page and the product listing page only show the name with maximum character limit and in the product info show it complete only in the description? In my site products with big names are getting over the page layout. If you wanna see the page click here Thanks, Luiz Tokuhara Link to comment Share on other sites More sharing options...
L!mit Posted October 7, 2008 Share Posted October 7, 2008 This can be done using substr(). You can lookup how to use the substr() function on the PHP website and then apply it to your code. BACKUP FIRST. Link to comment Share on other sites More sharing options...
Guest Posted October 9, 2008 Share Posted October 9, 2008 Thanks for your answer!!! But I got another one, sorry... I am newbie at PHP... Where can I insert that code? Thanks! <?php /* $Id: new_products.php,v 1.34 2003/06/09 22:49:58 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ ?> <script language="javascript"><!-- function popupWindow(url) { window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,res izable=yes,copyhistory=no,width=290,height=290,screenX=290,screenY=290,top=150,le ft=150'); } //--></script> <table cellpadding="0" cellspacing="0" border="0" width="100%" style="height:100%;"> <tr><td height="100%"> <table cellpadding="0" cellspacing="0" border="0" width="100%" style="height:100%;"> <tr> <td style="background:url(images/corner_bg_l.gif) left top repeat-y; "><img src="images/corner_t_l.jpg" alt=""></td> <td width="100%" style=" background-image:url(images/corner_bg_t.gif); background-position:left top; background-repeat:repeat-x; background-color:#ffffff;"> <table cellpadding="0" cellspacing="0" border="0" width="100%"> <?php $info_box_contents = sprintf(TABLE_HEADING_NEW_PRODUCTS, strftime('%B')); if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) { $new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where products_status = '1' order by RAND() limit " . MAX_DISPLAY_NEW_PRODUCTS); } else { $new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as 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 where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by RAND() limit " . MAX_DISPLAY_NEW_PRODUCTS); } ?> <tr><td> <? $col=0; while ($new_products = tep_db_fetch_array($new_products_query)) { $new_products['products_name'] = tep_get_products_name($new_products['products_id']); $product_query = tep_db_query("select products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$new_products['products_id'] . "' and language_id = '" . (int)$languages_id . "'"); $product = tep_db_fetch_array($product_query); $new_products['products_description'] = $product['products_description']; $p_price = '<span class="productMainPrice">'.$currencies->display_price($new_products['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])).'</span>'; if ($col!=0) echo '<td><img src="images/spacer.gif" width="7" height="1" alt=""></td>'; else echo '<br style="line-height:10px;"/><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr>'; ?> <td align="left" width="152"> <table cellpadding="0" cellspacing="0" border="0" width="151"> <tr><td> <table cellpadding="0" cellspacing="0" border="0" width="151"> <tr> <td style="background:url(images/prod_bg_l.gif) left top repeat-y; "><img src="images/prod_corn_t_l.gif" alt=""></td> <td width="100%" height="95" style="background:url(images/prod_bg_t.gif) left top repeat-x; padding:8px 0px 0px 0px;" align="center"><a style="color:#EAECD9;" href="<?=tep_href_link('product_info.php?products_id='.$new_products['products_id'])?>"><?=tep_thumb_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) ?></a></td> <td style="background:url(images/prod_bg_r.gif) right top repeat-y; "><img src="images/prod_corn_t_r.gif" alt=""></td> </tr> </table> </td></tr> <tr><td> <table cellpadding="0" cellspacing="0" border="0" width="100%"> <tr> <td><img src="images/prod_corn_m_l.gif" alt=""></td> <td width="100%" align="center" style="background:url(images/prod_m_bg.gif) left top repeat-x; padding:1px 0px 0px 0px;"><span><?=$new_products['products_name']?></span></td> <td><img src="images/prod_corn_m_r.gif" alt=""></td> </tr> </table> </td></tr> <tr><td> <table cellpadding="0" cellspacing="0" border="0" width="100%"> <tr> <td><a style="color:#EAECD9;" href="<?=tep_href_link('product_info.php?products_id='.$new_products['products_id'])?>"><?=tep_image("images/prod_btn_1.gif")?></a></td> <td><a href="<?= tep_href_link("products_new.php","action=buy_now&products_id=".$new_products['products_id'])?>"><?=tep_image("images/prod_btn_2.gif")?></a></td> <td width="100%" style="background:url(images/prod_bg_b.gif) left bottom repeat-x; padding:5px 0px 0px 11px;"><b><?=$p_price?></b></td> <td><img src="images/prod_corn_b_r.gif" alt=""></td> </tr> </table> </td></tr> </table> </td> <? if ($col==2) { echo '</tr></table>'; $col=0; } else $col++; } if ($col!=0) echo '</tr></table>'; ?> </table> </td> <td style="background:url(images/corner_bg_r.gif) left top repeat-y; "><img src="images/corner_t_r.jpg" alt=""></td> </tr> </table> </td></tr> <tr><td> <table cellpadding="0" cellspacing="0" border="0" width="100%"> <tr> <td><img src="images/corner_b_l.jpg" alt=""></td> <td width="100%" style="background:url(images/corner_bg_b.gif) left top repeat-x; "><img src="images/spacer.gif" width="1" height="1" alt=""></td> <td><img src="images/corner_b_r.jpg" alt=""></td> </tr> </table> </td></tr> </table> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.