Author Topic: Add category name before product name in category page  (Read 311 times)

amlil71

  • Beginner
  • *
  • Posts: 30
Add category name before product name in category page
« on: May 29, 2019, 13:14:46 pm »
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

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9024
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
Re: Add category name before product name in category page
« Reply #1 on: May 29, 2019, 16:25:09 pm »

$products[0]->category_name
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

amlil71

  • Beginner
  • *
  • Posts: 30
Re: Add category name before product name in category page
« Reply #2 on: May 29, 2019, 18:28:20 pm »
Hello John,

thank you for your answer. I replace code by :

Code: [Select]
<?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

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9024
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.4.2
Re: Add category name before product name in category page
« Reply #3 on: May 29, 2019, 20:41:53 pm »
$products[0]->category_name.' : '.$product->product_name
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3973
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Add category name before product name in category page
« Reply #4 on: May 30, 2019, 00:44:31 am »
More simple
$product->category_name.' : '.$product->product_name

amlil71

  • Beginner
  • *
  • Posts: 30
Re: Add category name before product name in category page
« Reply #5 on: May 30, 2019, 04:54:28 am »
Thank you very much John and Merci @studio 42 ! It's ok now. I will see if this change improve SEO ranking :)