Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

return only 50 chars from item title?


Guest

Recommended Posts

is it possible for me to return only 50 characters from the <?php echo $products_name; ?> command?

 

 

so instead of something like

 

item name - item title (mini desc)

 

 

 

it posts:

item name

 

 

...or, if it's any easier... all of my product titles and mini descriptions have a - separating them, so discarding anything after the - would be ideal.

 

i don't need this for the entire page. i wanted to create something like "want to be updated on new products from item name? enter your email" type of thing below the add to cart button.

 

i find that to be far more efficient than people requesting updates for specific items

Link to comment
Share on other sites

Try changing this

<?php echo $products_name; ?>

to

<?php echo (substr($products_name, 0, 50)); ?>

That will not work correctly if the product description is less than 50 so you really should expand the code to check for the length first.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

is it possible for me to return only 50 characters from the <?php echo $products_name; ?> command?

so instead of something like

 

item name - item title (mini desc)

it posts:

item name

...or, if it's any easier... all of my product titles and mini descriptions have a - separating them, so discarding anything after the - would be ideal.

 

i don't need this for the entire page. i wanted to create something like "want to be updated on new products from item name? enter your email" type of thing below the add to cart button.

 

i find that to be far more efficient than people requesting updates for specific items

 

add this function to your includes/functions/general.php

   function before ($this, $inthat)
  {
   return substr($inthat, 0, strpos($inthat, $this));
  };

 

then when calling on the part before the -, use this code:

<?php echo before(' - ', $products_name); ?>

:-)

Monika

 

addicted to writing code ... can't get enough of databases either, LOL!

 

my toolbox: Textpad - Compare and Merge - phpMyAdmin - WS_FTP - Photoshop - How to search the forum

 

Interactive Media Award July 2007 ~ category E-Commerce

my advice on the forum is for free, PMs where you send me work are considered consultation which I charge for ...

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...