Closed (fixed)
Project:
Custom Search
Version:
6.x-1.9
Component:
Taxonomy submodule
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
20 Oct 2011 at 20:51 UTC
Updated:
8 May 2013 at 20:50 UTC
Hi,
Is it possible to add subterms into search results?
For ex. we have following taxonomy structure for Location vocabulary:
Area A
-City A1
-City A2
...
-City An
Area B
-City B1
and so on...
On search box we select Area A1 and want to see results for all cities on this area.
I have googled for solution.. but found nothing.
The only way came up in my mind is to hack the code:
custom_search.module (function custom_search_submit)
after: $terms = array_map('_custom_search_filter_keys', array_values(array_filter($terms))); add the following code:
$sub_terms = array();
foreach ($terms as $tid) {
$childrens = taxonomy_get_children($tid);
if (is_array($childrens) && count($childrens)>0) {
foreach ($childrens as $child) {
$sub_terms[] = $child->tid;
}
}
}
if (is_array($sub_terms) && count($sub_terms)>0) {
$terms = array_merge($terms, $sub_terms);
}
It works fine for me but maybe I've missed something and there is a better way? If not.. can it be added in future release?
Comments
Comment #1
heddnI'm taking some liberty but a support request from 2011 is probably fixed or irrelevant. If you disagree, please reopen and provide more details. Perhaps please provide this in a patch.