Product title on front page short

Hi,

how I can make product titles on front page shorter. The title is sometime 1,2 or 3 rows. It

7 answers

Profile photo of Branislav Borojevic 0.00 $tone March 2, 2014
Public

You can open the file app\design\frontend\default\jm_megamalltemplate\c atalog\product\list.phtml and find the following code:

HTML Code:

<h5 class="product-name">
	<a title="<?php echo $this->htmlEscape($_product->getName()) ?>" href="<?php echo $_product->getProductUrl() ?>">
							<?php*
								if (strlen($_product->getName()) > 35) :
									echo strip_tags(substr($_product->getName(), 0, 35)).'...';
								else :*
									echo $_product->getName();
								endif;
							?>
	</a>
</h5>

Then change the value*(substr($_product->getName(), 0, 35)) from 35 to a lower number. That should make the title appear shorter on the front end.

Hope this helps You!

#2
Profile photo of Andreas Weiß 0.00 $tone March 3, 2014
Public

as attachment list.phtml.

EDIT: Dont work with upload:

here the file:

<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* egory design
* @package base_default
* Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<?php
/**
* Product list template
*
* @see Mage_Catalog_Block_Product_List
*/
?>
<div class="category-page">
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper(‘catalog/output’);
$baseconfig = Mage::helper("jmbasetheme")->getactiveprofile();

if ($baseconfig) :
$productlistimagewidth = $baseconfig["productlistimagewidth"];
$productlistimageheight = $baseconfig["productlistimageheight"];
$productlistdeslenght = $baseconfig["productlistdeslenght"];
$productgridimageheight = $baseconfig["productgridimageheight"];
$productgridimagewidth = $baseconfig["productgridimagewidth"];
$showlabel = $baseconfig["showlabel"];
else :
$productlistimagewidth = 150;
$productlistimageheight = 225;
$productlistdeslenght = 0;
$productgridimageheight = 225;
$productgridimagewidth = 150;
$showlabel = 0;
endif;
?>
<?php $addtocart = $this->__(‘Add to Cart’); ?>
<?php $preorder = $this->__(‘Pre-Order’); ?>

<?php if(!$_productCollection->count()): ?>
<p class="note-msg"><?php echo $this->__(‘There are no products matching the selection.’) ?></p>
<?php else: ?>
<div class="category-products">
<?php echo $this->getToolbarHtml() ?>
<?php // List mode ?>
<?php if($this->getMode()!=’grid’): ?>
<?php $_iterator = 0; ?>
<ol class="products-list" id="products-list">
<?php foreach ($_productCollection as $_product): ?>
<li class="item<?php if(++$_iterator == 1): echo ‘ first’; endif; if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
<div class="inner">
<?php // Product Image ?>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, ‘small_image’), null, true) ?>" class="product-image">
<img src="<?php echo $this->helper(‘catalog/image’)->init($_product, ‘small_image’)->resize($productlistimagewidth,$productlistimagehe ight); ?>" width="<?php echo $productlistimagewidth; ?>" height="<?php echo $productlistimageheight; ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, ‘small_image’), null, true) ?>" />
</a>
<?php // Product description ?>
<div class="product-shop">
<div class="f-fix">
<?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
<h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , ‘name’); ?></a></h2>
<?php echo $this->getReviewsSummaryHtml($_product, true, true)?>
<?php echo $this->getPriceHtml($_product, true) ?>
<div class="short-description">
<?php $sdesc = $_helper->productAttribute($_product, $_product->getShortDescription(), ‘short_description’) ?>
<?php
if ($productlistdeslenght) :
echo substr(strip_tags($sdesc), 0, $productlistdeslenght).’…’;
else :
echo $sdesc;
endif;
?>
</div>
<div class="btn-cart"></div>
<ul class="add-to-links">
<li>
<?php if($_product->isSaleable()): ?>
<button type="button" title="<?php if(Mage::getModel(‘cataloginventory/stock_item’)->loadByProduct($_product)->getQty()>0): echo $addtocart; else: echo $preorder; endif; ?>" class="button btn-cart" onclick="setLocation(‘<?php echo $this->getAddToCartUrl($_product) ?>’)"><span><span><?php if(Mage::getModel(‘cataloginventory/stock_item’)->loadByProduct($_product)->getQty()>0): echo $addtocart; else: echo $preorder; endif; ?></span></span></button>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__(‘Out of stock’) ?></span></p>
<?php endif; ?>
</li>
</ul>
</div>
</div>
</div>
</li>
<?php endforeach; ?>
</ol>
<script type="text/javascript">decorateList(‘products-list’, ‘none-recursive’)</script>

<?php else: ?>

<?php // Grid Mode ?>

<?php $_collectionSize = $_productCollection->count() ?>
<?php $_columnCount = $this->getColumnCount(); ?>
<?php
if($baseconfig["productgridnumbercolumn"]) :
$_columnCount = $baseconfig["productgridnumbercolumn"];
endif;
?>
<ul class="products-grid products-grid-special">
<?php $i=0; foreach ($_productCollection as $_product): ?>
<?php
$_rowCount = ceil($_collectionSize/$_columnCount);
if ($i%$_columnCount==0) : $j++; endif;
if ($i++%$_columnCount==0): $width = 100; endif;
if ($_columnCount):
$width = 100/$_columnCount;
$width = "style=\"width:{$width}%;\"";
endif;
$return = false;
?>
<li class="item <?php if ($j==$_rowCount) : echo "item-row-last"; endif; ?> <?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>" <?php echo $width; ?>>
<div class="inner">
<div class="product-image">
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, ‘small_image’), null, true) ?>">
<img src="<?php echo $this->helper(‘catalog/image’)->init($_product, ‘small_image’)->resize($productgridimagewidth,$productgridimagehe ight); ?>" width="<?php echo $productgridimagewidth; ?>" height="<?php echo $productgridimageheight; ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, ‘small_image’), null, true) ?>" />
<?php if ($labeltype && $showlabel): ?>
<span class="ico-label <?php echo $labeltype; ?>-label"><?php echo $labelname; ?></span>
<?php endif; ?>
</a>
<div class="actions">
<?php if($_product->isSaleable()){ ?>
<button type="button" title="<?php if(Mage::getModel(‘cataloginventory/stock_item’)->loadByProduct($_product)->getQty()>0): echo $addtocart; else: echo $preorder; endif; ?>" class="button btn-cart" onclick="setLocation(‘<?php echo $this->getAddToCartUrl($_product) ?>’)"><span><span><?php if(Mage::getModel(‘cataloginventory/stock_item’)->loadByProduct($_product)->getQty()>0): echo $addtocart; else: echo $preorder; endif; ?></span></span></button>
<?php } else { ?>
<div class="out-of-stock"><?php echo $this->helper("catalog")->__(‘Out of stock’) ?></div>
<?php } ?>

<?php if($productgriddeslenght) : ?>
<p class="pdescription"><?php echo substr(nl2br(strlen($_product->getDescription()) > 10 ? $_product->getDescription() : $_product->getShortDescription()), 0, $productgriddeslenght).’…’;?></p>
<?php endif; ?>
</div>
</div>
<h5 class="product-name">
<a title="<?php echo $this->htmlEscape($_product->getName()) ?>" href="<?php echo $_product->getProductUrl() ?>">
<?php
if (strlen($_product->getName()) > 35) :
echo strip_tags(substr($_product->getName(), 0, 25)).’…’;
else :
echo $_product->getName();
endif;
?>
</a>
</h5>
<?php echo $this->getReviewsSummaryHtml($_product, true, true)?>
<?php echo $this->getPriceHtml($_product, true) ?>

</div>
</li>
<?php endforeach ?>
</ul>
<script type="text/javascript">decorateGeneric($$(‘ul.products-grid’), [‘odd’,’even’,’first’,’last’])</script>
<?php endif; ?>
<div class="toolbar-bottom">
<?php echo $this->getToolbarHtml() ?>
</div>
</div>
<?php endif; ?>
</div>

#4
Profile photo of nickydg 0.00 $tone March 4, 2014
Public

You need to change code in this file:
app\design\frontend\default\jm_megamalltemplate\j oomlart\jmproducts\list.phtml

Replace:

HTML Code:

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

With:

HTML Code:

<h5 class="product-name">
	<a title="<?php echo $this->htmlEscape($_product->getName()) ?>" href="<?php echo $_product->getProductUrl() ?>">
		<?php
			if (strlen($_product->getName()) > 35) :
				echo strip_tags(substr($_product->getName(), 0, 35)).'...';
			else :
				echo $_product->getName();
			endif;
		?>
	</a>
</h5>

Hope this helps.

#5

This question is now closed

Written By

Comments