- Posts: 14
COMMUNITY FORUM
[SOLVED] Show parentcategory in Category-item.php
- Benana
- Topic Author
- Offline
- New Member
Less
More
12 years 2 months ago - 12 years 2 months ago #102980
by Benana
[SOLVED] Show parentcategory in Category-item.php was created by Benana
Hi,
is it possible to show in category-item.php (override) the parent category of an item?
At the moment I only see the parent id...
is it possible to show in category-item.php (override) the parent category of an item?
At the moment I only see the parent id...
Log in or Create an account to join the conversation.
- Lefteris
- Offline
- Moderator
Less
More
- Posts: 8743
12 years 2 months ago #102981
by Lefteris
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Lefteris on topic Re: Show parentcategory in Category-item.php
Hi. Try something like that:
<?php
$parent = JTable::getInstance('K2Category', 'Table');
$parent->load($this->item->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.
- Benana
- Topic Author
- Offline
- New Member
Less
More
- Posts: 14
12 years 2 months ago #102982
by Benana
Replied by Benana on topic Re: Show parentcategory in Category-item.php
Thanks!
It works great!
It works great!
Please Log in or Create an account to join the conversation.
- Lefteris
- Offline
- Moderator
Less
More
- Posts: 8743
12 years 2 months ago #102983
by Lefteris
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Lefteris on topic Re: Show parentcategory in Category-item.php
You are welcome.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Ardiansyah
- Offline
- New Member
Less
More
- Posts: 6
11 years 10 months ago #102984
by Ardiansyah
i using this in category.php v.2.6.2 notwoking
Replied by Ardiansyah on topic Re: Show parentcategory in Category-item.php
Lefteris Kavadas wrote: Hi. Try something like that:
<?php $parent = JTable::getInstance('K2Category', 'Table'); $parent->load($this->item->category->parent); echo $parent->name; ?>
i using this in category.php v.2.6.2 notwoking
Please Log in or Create an account to join the conversation.
- schug.trent
- Offline
- New Member
Less
More
- Posts: 6
11 years 5 months ago #102985
by schug.trent
Replied by schug.trent on topic Re: Show parentcategory in Category-item.php
Has anyone figured this out for the newer version, K2 Version 2.6.6 ??
I want to display the image of the parent category in the category.php template. I tried the suggestion above, but it did not work.
I want to display the image of the parent category in the category.php template. I tried the suggestion above, but it did not work.
Please Log in or Create an account to join the conversation.
- schug.trent
- Offline
- New Member
Less
More
- Posts: 6
11 years 5 months ago #102986
by schug.trent
Replied by schug.trent on topic Re: Show parentcategory in Category-item.php
I got it. To bring the parent name in the category.php here is the code:
Log in or Create an account to join the conversation.
- Alexander Ioannidis
- Offline
- Senior Member
Less
More
- Posts: 65
10 years 1 month ago #102987
by Alexander Ioannidis
Replied by Alexander Ioannidis on topic Re: Show parentcategory in Category-item.php
Hey guys, thanks for this info. Just to add my bit, hoping it will be helpful to someone else:
I needed to get the ID of a category's parent category in the category.php file, so my code is
And then to output the value
Tested and working on 2.7.0 (development version)
I needed to get the ID of a category's parent category in the category.php file, so my code is
<?php
// Get the parent category name
$parent = JTable::getInstance('K2Category', 'Table');
$parent->load($this->category->parent);
$myparentid = $parent->id;
?>
And then to output the value
<?php echo $myparentid; ?>
Tested and working on 2.7.0 (development version)
Please Log in or Create an account to join the conversation.