- Posts: 3
- Thank you received: 0
OS Property support center
How to display the name of the parent category?
- Rashit
- Topic Author
- Offline
- New Member
-
Less
More
12 years 3 months ago - 12 years 3 months ago #23714
by Rashit
How to display the name of the parent category? was created by Rashit
Hi !
There are 2 categories with subcategories. When I do advanced search in subcategories, it shows the name of subcategory only in results listing.
The code that doing this is
<?php echo $row->category_name?>
in results.html.tpl.php.
But I want to display full path to found properties (ex. category - subcategory) in results page.
How to "echo" parent category`s name before the subcategory name?
Please help.
There are 2 categories with subcategories. When I do advanced search in subcategories, it shows the name of subcategory only in results listing.
The code that doing this is
<?php echo $row->category_name?>
in results.html.tpl.php.
But I want to display full path to found properties (ex. category - subcategory) in results page.
How to "echo" parent category`s name before the subcategory name?
Please help.
Last edit: 12 years 3 months ago by Rashit.
Please Log in or Create an account to join the conversation.
- Mr. Dam
-
- Offline
- Administrator
-
Less
More
- Posts: 13020
- Thank you received: 1688
12 years 3 months ago #23726
by Mr. Dam
Replied by Mr. Dam on topic Re: How to display the name of the parent category?
Hi,
The solution is change :
<?php echo $row->category_name?>
to
<?php
if($row->category_id > 0){
$db = Jfactory::getDBO();
$db->setQuery("Select parent_id from #__osrs_categories where id = '$row->category_id'");
$parent_id = $db->loadResult();
if($parent_id > 0){
$db->setQuery("Select category_name from #__osrs_categories where id = '$parent_id'");
echo $db->loadResult()." - ";
}
echo $row->category_name;
}
?>
Good luck
Dam
The solution is change :
<?php echo $row->category_name?>
to
<?php
if($row->category_id > 0){
$db = Jfactory::getDBO();
$db->setQuery("Select parent_id from #__osrs_categories where id = '$row->category_id'");
$parent_id = $db->loadResult();
if($parent_id > 0){
$db->setQuery("Select category_name from #__osrs_categories where id = '$parent_id'");
echo $db->loadResult()." - ";
}
echo $row->category_name;
}
?>
Good luck
Dam
Please Log in or Create an account to join the conversation.
- Rashit
- Topic Author
- Offline
- New Member
-
Less
More
- Posts: 3
- Thank you received: 0
12 years 3 months ago #23788
by Rashit
Replied by Rashit on topic Re: How to display the name of the parent category?
Thank you very much. It works.
Please Log in or Create an account to join the conversation.
Moderators: Mr. Dam, Nguyen Phu Quan
Support
Documentation
Information
Copyright © 2025 Joomla Extensions by Joomdonation. All Rights Reserved.
joomdonation.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.