Jump to content

Character Count Limit In Display Output


FidelGonzales

Recommended Posts

I have lurked this site for several years, usually answering my questions through extensive use of the search function. So, finally, here's my first post.

 

On a shopping cart, for the purpose of design layout consistency, I need to reduce the display of the product name text character count. Currently, the character count is only limited by the limitations listed in the database. That limit of 300 characters is fine, but for specific pages in the template, I need the character count limit to be somewhere around 21.

 

Below are a few of the options I have tried. None have worked. I would appreciate any assistance. Any suggestions? Thanks.

 

ORIGINAL CODE

 

<td align="center" valign="top"> <strong><a title="<?php echo $product_name ?>" href="<?php echo $product_flypage ?>"><?php echo $product_name ?><br>

              <?php echo $product_sku ?></a> </strong></td>

 

WORD LIMIT - Renders the number 4

 

<td align="center" valign="top"> <strong><a title="<?php echo $product_name ?>" href="<?php echo $product_flypage ?>"><?php echo $product_name; $numwords = 4 ?><br>

              <?php echo $product_sku ?></a> </strong></td>

 

CHARACTER LIMIT - Renders the number 50

 

<td align="center" valign="top"> <strong><a title="<?php echo $product_name ?>" href="<?php echo $product_flypage ?>"><?php echo $limit = 50; $product_name ?><br>

              <?php echo $product_sku ?></a> </strong></td>

Link to comment
https://forums.phpfreaks.com/topic/201597-character-count-limit-in-display-output/
Share on other sites

Figures that after I searched and searched that immediately after I posted I would figure out how to solve the problem. This isn't pretty, but it does the job. Thanks for looking.

 

 

<td align="center" valign="top"> <strong><a title="<?php echo $product_name ?>" href="<?php echo $product_flypage ?>"><?php 

$length = 20 ;
$text = "$product_name" ;
$display = substr($text, 0, $length) ;
echo $display;
echo "..." ;		

		 ?><br>
              <?php echo $product_sku ?></a> </strong></td>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.