News:

Support the VirtueMart project and become a member

Main Menu

Limite Product titles in 'Related Products'

Started by buddy123, August 28, 2013, 14:58:08 PM

Previous topic - Next topic

buddy123

I would like to limit the product title under 'Related Products' on a product view page.

I know about custom templating and on the product details view page:

<?php if (!empty($this->product->customfieldsRelatedProducts)) : ?>
<div class="product-related-products">
<h4 class="title"><?php echo JText::_('COM_VIRTUEMART_RELATED_PRODUCTS'); ?></h4>
<?php foreach ($this->product->customfieldsRelatedProducts as $field) : ?>
<div class="product-field-type-<?php echo $field->field_type ?>"> <span class="product-field-display"><?php echo $field->display ?>
</span>  </div>
<?php endforeach; ?>
</div>
<?php endif; ?>


I can't figure out how to limit the length of the product title to say 15 characters.  I read on the forum about using <?php echo shopFunctionsF::limitStringByWord ($product->product_name, 40, '...') ?> but I don't understand how to apply it in this context.

Maxim Pishnyak

You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

PRO

you cannot do this, because the whole display is in a single variable.


Maxim Pishnyak

You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

jenkinhill

I have used code similar to this (for VM1.1) on another component to truncate the display of a title. Maybe something similar could be used here?  http://forum.virtuemart.net/index.php?topic=49564.msg159085#msg159085
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum