News:

Support the VirtueMart project and become a member

Main Menu

Call Child Category through PHP

Started by SoTrue, August 06, 2018, 14:47:53 PM

Previous topic - Next topic

SoTrue

Hi Guys,

I am trying to add the category and child category programmatically, but am not sure of the variable for the child category. I have the code below, however after .$category->category_name I would then like to add the subcategory name if it is a sub category and if there is no subcategory remove the .$category->category_name completely.

$document->setTitle("Buy Womens and Mens Clothing".$category->category_name);
if ($this->app->getCfg('MetaTitle') == '1') {
$document->setMetaData('title',  $title);
}


Can any one advise how i can achieve this?

Best Regards
Donna

GJC Web Design

you can have multiple child cats

you can do something like

$html_title = "Buy Womens and Mens Clothing ".$category->category_name;

if ($this->category->haschildren) {

foreach ( $this->category->children as $subcategory ) {
    $html_title = $html_title.' '.$subcategory->->category_name
}

}

$document->setTitle($html_title);
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