News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Limit product title in frontpage

Started by stefan5159, September 22, 2012, 23:51:35 PM

Previous topic - Next topic

stefan5159

Hi,

Iam trying to limit the product titles in my frontpage to max 15 characters and if it breaks show .... I think the code is:

               <h3>
               <?php // Product Name
               echo JHTML::link ( JRoute::_ ( 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id), $product->product_name, array ('title' => $product->product_name ) ); ?>
               <?php ?></h3>

Don't know much about php but I think it needs to be substringed, can anyone help me?

bytelord

#1
Hello,

Haven't tested but could be like this:

<h3>
<?php // Product Name
               
echo JHTML::link JRoute::'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' $product->virtuemart_product_id '&virtuemart_category_id=' $product->virtuemart_category_id), $product->product_name, array ('title' => shopFunctionsF::limitStringByWord($product->product_name15'...') ) ); 
?>
</h3>


uses shopFunctionsF::limitStringByWord to limit the characters to 15 and place also "..."

Hope helps you out
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

stefan5159

Hi thanks for your reply but that does not do anything. I eddited the file components/com_virtuemart/views/virtuemart/default_products.php by changing the the code:

               <h3>
               <?php // Product Name
               echo JHTML::link ( JRoute::_ ( 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id), $product->product_name, array ('title' => $product->product_name ) ); ?>
               <?php ?></h3>

To yours

<h3>
<?php // Product Name
               echo JHTML::link ( JRoute::_ ( 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id), $product->product_name, array ('title' => shopFunctionsF::limitStringByWord($product->product_name, 15, '...') ) );
?></h3>

It had no effect

(my website frontpage can be found here www.tarotkaart.com)

bytelord

Sorry,

That was only for the tooltip title ... both will be with the same function usage

<h3>
<?php // Product Name
              
echo JHTML::link JRoute::'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' $product->virtuemart_product_id '&virtuemart_category_id=' $product->virtuemart_category_id ), shopFunctionsF::limitStringByWord($product->product_name15'...'), array ('title' => shopFunctionsF::limitStringByWord($product->product_name15'...') ) );
?>
</h3>


or the tooltip title name be full

<h3>
<?php // Product Name
echo JHTML::link JRoute::'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' $product->virtuemart_product_id '&virtuemart_category_id=' $product->virtuemart_category_id ), shopFunctionsF::limitStringByWord($product->product_name15'...'), array ('title' => $product->product_name ) ); ?>

</h3>



PS: On the above example will be 15 char title name + "...", you can change it as you wish

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

stefan5159


CenturionSigns

Hi!  Great thread.  Jumping in because I am trying to create a similar character limit in product names on the category view.  I pasted the code you gave in the file you mentioned, but see no effect?

http://www.centurionsafetysigns.co.uk/buyonline/index.php/mandatory-signs/construction-signage

bytelord

Hello,

Please explain better where did you post it, inside your overrides? Which override? VM2 Version, joomla?

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

CenturionSigns

No, I followed the instructions above.  "the file components/com_virtuemart/views/virtuemart/default_products.php"

bytelord

that path missing the tml folder but the category view is not located there, this is the front page. It seems that you haven't read at all the forum related to template overrides. Just create a template override for category view, but as i see your site i think you are already use template overrides ... but in any case read carefully.

To create a template override for category view just copy the file joomla_root_folder/components/com_virtuemart/views/category/tmpl/default.php under joomla_root_folder/templates/your_joomla_template/html/com_virtuemart/category/default.php
If the folders are not exist please create them ... if you already use template overrides edit the overridden file and don't copy that file again.

Now, just edit the destination file (the copied one or the one your already have) and place that cope where the category title produced and will work, if doesn't work ask your template provider.

Use firebug to examine you site code and css styling: https://forum.virtuemart.net/index.php?topic=102850.0

Template Overrides:
Creating Template overrides: https://forum.virtuemart.net/index.php?topic=98505.0
Template System: https://dev.virtuemart.net/projects/virtuemart/wiki/Hints_for_the_use_of_the_template_system

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!