News:

Support the VirtueMart project and become a member

Main Menu

Add category name before product name in category page

Started by amlil71, May 29, 2019, 13:14:46 PM

Previous topic - Next topic

amlil71

Hello,

in my category page i have this code which show product name of product:

<div class="Title">
<?php echo JHTML::link(JRoute::_($product->link.$ItemidStr), shopFunctionsF::limitStringByWord($product->product_name,'50','...'), array ('title' => shopFunctionsF::limitStringByWord($product->product_name, 50, '...') ) ); ?>
</div>

I want to add the category name before the product name as this : "Catégory name : product name"

How can i get this with category_name?

I try this code but it does'nt work :

<div class="Title">
<?php echo JHTML::link(JRoute::_($product->link.$ItemidStr), shopFunctionsF::limitStringByWord($category->category_name, ':', $product->product_name,'50','...'), array ('title' => shopFunctionsF::limitStringByWord($category->category_name, ':', $product->product_name, 50, '...') ) ); ?>
</div>

Thank you for your help.

regards.

GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

amlil71

Hello John,

thank you for your answer. I replace code by :

<?php echo JHTML::link(JRoute::_($product->link.$ItemidStr), shopFunctionsF::limitStringByWord($products[0]->category_name,'50','...'), array ('title' => shopFunctionsF::limitStringByWord($products[0]->category_name50'...') ) ); ?>


I have category name in place of product name. I want to have category name and product name.

Example : Category : bags
                Product : Black Bag

I want this title : " Bag : Black Bag".

Thank you for your help.

Regards.
Hamid.

GJC Web Design

$products[0]->category_name.' : '.$product->product_name
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Studio 42

More simple
$product->category_name.' : '.$product->product_name

amlil71

Thank you very much John and Merci @studio 42 ! It's ok now. I will see if this change improve SEO ranking :)