Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Set maximum character lenght for Related Product titles
 
criatweb
Jr. Member
 
Total Posts:  13
Joined:  2012-07-09
 

Hello, I would like to set a max characters limit to the related products titles, like:

<b>UltraBook Acer S3-391-6632 C/ Intel Core i3 2367M, 4GB, HD 320GB + 20GB SSD, Webcam, Wind7hb - 13.3´ LED</b>
would become
<b>UltraBook Acer S3-391-6632 (...)</b>

To avoid breaking the website layout, a title with maximum of 35 characters, then it adds (...).

/www/app/design/frontend/base/default/template/catalog/product/list/related.phtml

<div class="product-details">
 <!-- -Function 
to add the character limit -->     <class="product-name"><a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->htmlEscape($_item->getName()) ?></a></p>
                     <
div class="related_prices_box"><?php echo $this->getPriceHtml($_itemtrue'-related'?></div>
                    </
div>

My current Related Product tabs:
http://i49.tinypic.com/28vvwg.jpg

I’ll mess with the prices too, of course, I just need to find a way to set a different style for product main page and related product sidebar

 
Magento Community Magento Community
Magento Community
Magento Community
 
Magestore
Mentor
 
Avatar
Total Posts:  1015
Joined:  2009-08-07
Viet Nam
 

Hi criatweb,

To set maximum character length for Related Product titles, you can change line code which shows product name as bellow:

<class="product-name"><a href="<?php echo $_item->getProductUrl() ?>"><?php echo substr_replace($this->htmlEscape($_item->getName()),"..."35);?></a></p>

Hope this helps

Best Regards,
Magestore

 
Magento Community Magento Community
Magento Community
Magento Community
 
criatweb
Jr. Member
 
Total Posts:  13
Joined:  2012-07-09
 

Hello magestore!

It works like a charm, thanks a lot!!!!!

http://i45.tinypic.com/71oj1u.jpg

I hate to abuse of your good will, but maybe if you could take a look at this other topic, you might know the solution as well:
http://www.magentocommerce.com/boards/viewthread/291996/

I want to set different price styles for Product Page, Related Products and Home Page, as you can see I must lower the price size on related products, but if I do that, it lowers on product page and home as well :o, I want to split that :]

But thanks a lot for the solution so far, it really helped me!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
criatweb
Jr. Member
 
Total Posts:  13
Joined:  2012-07-09
 

up topic :]

 
Magento Community Magento Community
Magento Community
Magento Community
 
florbonia
Jr. Member
 
Total Posts:  3
Joined:  2013-04-01
 

Hi everybody

I try to do this in my theme but i can fix it. Everybody can help me?

My code is:

<h2 class=\\\"product-name\\\"><a href=\\\"<?php echo $_product->getProductUrl() ?>\\\" title=\\\"<?php echo $this->htmlEscape($_product->getName()) ?>\\\"><?php echo $this->htmlEscape($_product->getName()) ?></a></h2>

and I don\\\’t understand where I have to put the code to limit the charcters.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top