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

heddn’s picture

Status: Active » Fixed

I'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.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.