Support Forums

show category names in search results

This is a discussion on show category names in search results within the Templates, HTML, CSS, and Design Help forums, part of the General category; is it possible to show category names in search results/listings? I used {debug} but couldn't find any variable available for ...


Go Back   68 Classifieds Forums > General > Templates, HTML, CSS, and Design Help

Reply
 
Thread Tools Display Modes
Old 12-03-2009, 02:29 PM   #1
Customer
 
Join Date: Jun 2008
Location: Maldives
Posts: 134
Rep Power: 16
business is on a distinguished road
Default show category names in search results

is it possible to show category names in search results/listings? I used {debug} but couldn't find any variable available for category name of the listings. anyway this can be done?
__________________
v 4.2.0 Developer - Default Template
business is offline   Reply With Quote
Old 12-03-2009, 02:37 PM   #2
curmudgeon
 
Join Date: Mar 2006
Posts: 5,413
Rep Power: 138
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

the closest thing you have is the category ID which is in the {$results} array. If you dont have too many categories you could add smarty logic to check the value of that array field and in turn display the category name.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline   Reply With Quote
Old 12-03-2009, 03:04 PM   #3
Customer
 
Join Date: Jun 2008
Location: Maldives
Posts: 134
Rep Power: 16
business is on a distinguished road
Default

yeah ... {$entry.section} is giving the category id. with close to 100 categories, i am not sure if it is a good idea to use {if} to display the category name... but that's an option. thanks.
__________________
v 4.2.0 Developer - Default Template
business is offline   Reply With Quote
Old 12-03-2009, 03:14 PM   #4
curmudgeon
 
Join Date: Mar 2006
Posts: 5,413
Rep Power: 138
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by business
yeah ... {$entry.section} is giving the category id. with close to 100 categories, i am not sure if it is a good idea to use {if} to display the category name... but that's an option. thanks.
The name of the category is not stored with the rest of the ad data so that leaves you 3 options.

Alter the function that gets the ad data to do an extra call to the database for every product and look up the name of the category.

alter the function that gets the adds and add in a join in the database query so it gets the category name when it gets the ad data......this could be very complex since the search already builds a fairly complex query based on input.

Lastly, the method I mentioned above.


Im not a big fan of hacking code because it makes upgrades troublesome so I would opt for the template method first. You can probably enable the debug mod in admin and see how badly it effects the page display but my guess is it will have a minimal impact.


I suppose you could create a plugin to do the category name query and insert it into the loop that goes over the $result array. However this method MAY have a greater impact on the server than doing the IF at the template level.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline   Reply With Quote
Old 12-03-2009, 03:36 PM   #5
Customer
 
Join Date: Jun 2008
Location: Maldives
Posts: 134
Rep Power: 16
business is on a distinguished road
Default

i too would like to avoid modifying core files.
what I plan is use the {if} statement in a new tpl file and {include} it in the showlisting file so that I can keep the code clean in this file.
My plan is to enable admin users to view the category names in searches / latest listings so that I can easily check if the customers have put the items in the correct category without having to view each listing.
thanks for the help.
__________________
v 4.2.0 Developer - Default Template
business is offline   Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I add Category to search results??? naidu01 Technical Support 2 08-31-2009 03:30 AM


All times are GMT -4. The time now is 01:25 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0