Hi,
I am trying to change the "Posted in" link at the bottom of an item to show links to the parent category and the current one, like a breadcrumb type of structure. Does anyone know how to call the parent category in the PHP file?
Here is what I have to call the current category only (file: com_k2/templates/default/category.php).
I am trying to change the "Posted in" link at the bottom of an item to show links to the parent category and the current one, like a breadcrumb type of structure. Does anyone know how to call the parent category in the PHP file?
Here is what I have to call the current category only (file: com_k2/templates/default/category.php).
Topic Author
13 years 3 days ago #120661
Thanks for the reply.
It doesn't quite work. Here is what the code looks like now:
It doesn't quite work. Here is what the code looks like now:
13 years 2 days ago #120662
Hi. Try to use:
<?php
$category = JTable::getInstance('K2Category', 'K2Table');
$category->load($this->item->catid);
$parent = JTable::getInstance('K2Category', 'K2Table');
$parent->load($category->parent);
echo $parent->name;
?>
Topic Author
13 years 2 days ago #120663
Hi. Thanks for the repply.
The page doesn't load and I get this error: "Fatal error: Call to a member function load() on a non-object in /home4/bsihost/public_html/joomla3/components/com_k2/templates/default/item.php on line 186".
Line 186 has this:
The page doesn't load and I get this error: "Fatal error: Call to a member function load() on a non-object in /home4/bsihost/public_html/joomla3/components/com_k2/templates/default/item.php on line 186".
Line 186 has this:
12 years 11 months ago #120664
<?php
JTable::addIncludePath(JPATH_ADMINISTRATOR.'/components/com_k2/tables');
$category = JTable::getInstance('K2Category', 'K2Table');
$category->load($this->item->catid);
$parent = JTable::getInstance('K2Category', 'K2Table');
$parent->load($category->parent);
echo $parent->name;
?>Log in or create an account to reply.