News:

Support the VirtueMart project and become a member

Main Menu

Parent category on a child cat page

Started by bodrilo, January 25, 2013, 09:28:52 AM

Previous topic - Next topic

bodrilo

I want to print the parent category name on a child category page

the current category name prints out like this
echo $this->category->category_name

but how do i get the parent category?

K&K media production

Hi

please try this code:


$q = 'SELECT `category_parent_id` FROM `#__virtuemart_category_categories` WHERE `category_child_id`=' . $this->category->virtuemart_category_id;
$db = JFactory::getDbo();
$db->setQuery($q);
$parentCategoryID = $db->loadResult();

if ($parentCategoryID != '0') {
   $categoryModel = VmModel::getModel('category');
   $parentCategory = $categoryModel->getCategory($parentCategoryID);

   echo $parentCategory->category_name;
}



Regards,
Maik

bodrilo


kobiavr

thank you kkmediaproduction
this is help me but i have a problem

i i have a deep category like:
category1 -> subcategory1 -> subcategory2

in the page of subcategory2 i get the name of subcategory1
how can i get on subcategory2 the name of category1

kobi