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

How to Truncate Product Titles in New Products? 
 
txl_series5
Jr. Member
 
Total Posts:  2
Joined:  2009-01-22
 

Hi there -

I’m looking to truncate the product titles in the New Products widget on my home page.
(I researched the forum before posting this question; I found similar answers, but need additional help.)

I’d like all the product titles to have a consistent amount of characters (for example, 30).

If anyone can take me through this step-by-step, I will be incredibly and astoundingly grateful to you!

Sincere thanks,
Jenny

 
Magento Community Magento Community
Magento Community
Magento Community
 
txl_series5
Jr. Member
 
Total Posts:  2
Joined:  2009-01-22
 

I figured it out.

I editied this file:
/apps/magento/htdocs/app/design/frontend/default/THEME NAME/template/catalog/product/widget/new/content/new_grid.phtml (since I am using the grid view)

Original code:

<h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>)"><?php echo $this->helper('catalog/output')->productAttribute($_product$_product->getName() , 'name'?></a></h3>
            </
li>
        
<?php if ($i%$_columnCount==|| $i==count($_products)): ?>
        
</ul>
        
<?php endif ?>
        <?php 
endforeach; ?>
    
</div>
</
div>
New code:
<?php $ProdShortName $this->helper('catalog/output')->productAttribute($_product$_product->getName() , 'name'); ?>

<h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>)"><?php echo $this->helper('core/string')->truncate($ProdShortName,25,'...'$_remaindertrue); ?></a></h3>
            </
li>
        
<?php if ($i%$_columnCount==|| $i==count($_products)): ?>
        
</ul>
        
<?php endif ?>
        <?php 
endforeach; ?>
    
</div>
</
div>
<?php endif; ?>

Hopefully this can also help someone else.

Sincerely,
Jenny

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