Right now, when you have the 'filter by categories' box on, the terms matching the search keyword are listing in a box ordered by term by weight then alphabetically.

It may be more intuitive to group them by vocab name and list the vocab name title above each grouping. So, instead of:

apples (2)
bananas (3)
carrots (5)
grapes (3)
lettuce (5)
spinach (1)
passion fruit (4)
pineapple (8)

You get:

Fruits
-apples (2)
-bananas (3)
-grapes (3)
-passion fruit (4)
-pineapple (8)

Veggies
-carrots (5)
-lettuce (5)
-spinach (1)

Does this listing seem easier to make sense of?

My only lead is taking the sql query in case 'terms' in the node_trip_search function, joining to the vocabulary table, then, this might be a little hackish or maybe it's the best way, but making v.vid first in the query, and also make v.name available, then using this function:

 function groupbyfirst($array) {
   foreach ($array as $row)
   {
       $firstkey = array_keys($row);
       $firstkey = $firstkey[0];
       $key = $row[$firstkey];
       unset($row[$firstkey]);
       $newarray[$key][] = $row;
   }
   return $newarray;
} 

from http://www.php.net/manual/en/function.array-combine.php#50389 (whereas array_combine is for php5+, this will work with 4)

To make a multidimensional array which will combine the arrays based on their first key (vid). Then, so you've got the multidimensional array, and v.name as a key for each second dimension array. Then, I guess themeing this is the trick. Or is there a much easier way to get the same results? Like a taxonomy_get_tree_if_nodes function, which doesnt exist, just another idea.

Ian

Comments

joel_guesclin’s picture

Status: Active » Closed (fixed)

This has changed in the version for 4.7, which uses standard Drupal API to get the form. Check it out and see what you think