- Posts: 3
COMMUNITY FORUM
"Posted in" link to Parent category
- leticia queiroz
- Topic Author
- Offline
- New Member
Less
More
10 years 10 months ago #120659
by leticia queiroz
"Posted in" link to Parent category was created by leticia queiroz
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).
Log in or Create an account to join the conversation.
- Yiota
- Visitor
10 years 10 months ago #120660
by Yiota
Replied by Yiota on topic Re: "Posted in" link to Parent category
Give it a try with this $this->category->parent
Please Log in or Create an account to join the conversation.
- leticia queiroz
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
10 years 10 months ago #120661
by leticia queiroz
Replied by leticia queiroz on topic Re: "Posted in" link to Parent category
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:
Log in or Create an account to join the conversation.
- Lefteris
- Offline
- Moderator
Less
More
- Posts: 8743
10 years 10 months ago #120662
by Lefteris
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Lefteris on topic Re: "Posted in" link to Parent category
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;
?>
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- leticia queiroz
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
10 years 10 months ago #120663
by leticia queiroz
Replied by leticia queiroz on topic Re: "Posted in" link to Parent category
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:
Log in or Create an account to join the conversation.
- Lefteris
- Offline
- Moderator
Less
More
- Posts: 8743
10 years 10 months ago #120664
by Lefteris
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Lefteris on topic Re: "Posted in" link to Parent category
<?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;
?>
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.