In single product page, I have an array of category ids. I want to display the titles of these categories. Anyone have the code handy, or know where to find it?
Basically I want the function to get the category title by providing its id.
Thanks
Try this:
Quote
$active_category_id = vRequest::getInt('virtuemart_category_id', '0');
$category = $categoryModel->getCategory($active_category_id, false, false);
$catname = $category->category_name;
Thanks, I am getting an error about '$categoryModel'. It's probably not defined in the product page. How do I reference that?
Thanks
Try this code before another:
$categoryModel = VmModel::getModel('Category');
are you wanting the categories info the product is in? Like all the categories the product is in? The data is already available on product page.
Its available with $this->product->categoryItem
The code below isnt exactly what you want, but you can see the variables and how i do it.
foreach ($this->product->categoryItem as $category){
if ($category['published']==0)continue;
if ($category['virtuemart_category_id']==85)continue;
$caturl = JRoute::_ ( 'index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $category['virtuemart_category_id'] );
$catname=$category['category_name'];
$categoriescombined[]= array($caturl,$catname,$category['virtuemart_category_id']);
$skip2[]=$category['virtuemart_category_id'];
}
Thank you very much!
I am not looking for the categories the product is in, in this case, but thanks for the info it will definitely be useful!