Hi all,

I've searched the solution for about a week, but i didn't find it. The main request was simple: rebuild the option list of the hierarchical select by the given option list.

here is a small example:

$posible_options = array_keys($options); //example: $options = (1234 => 'term1', 5232 => 'term2');
    $vtree = taxonomy_get_tree($vid);

    if($vtree) {
      $ret_options = array();
        foreach ($vtree as $key => $term) {
          $choice = new stdClass();
          if(in_array($term->tid, $posible_options)) {
            $choice->option = array($term->tid => str_repeat('-', $term->depth) . $term->name);
            $ret_options[] = $choice;
          }
        }
    }

    return array_merge(array(
      '#type' => 'hierarchical_select',
      '#title' => $title,
      '#default_value' => $default_value,
      '#options' => $ret_options,
      '#config' => array(
        'module' => 'hs_taxonomy',
        'params' => array(
          'vid' => $vid,
        ),
        'save_lineage'    => 0,
        'enforce_deepest' => 0,
        'resizable' => 0,
      ),
    ), $more_options);

Comments

cleverhoods’s picture

Category: task » bug
wim leers’s picture

Category: bug » support
Priority: Normal » Minor
Status: Active » Postponed (maintainer needs more info)

The answer is simple and already included: hs_smallhierarchy. Apparently it's not yet documented in the README.txt nor in the API.txt file, for which I apologize.

There's some documentation in modules/hs_smallhierarchy.module, starting at line 110. That's what the 'hierarchy' parameter should look like. Pass in a unique ID for the 'id' parameter and the pipe ('|') or any other symbol for the 'separator' parameter.

I'll write proper documentation for this when I find the time. Hopefully the above is sufficient to get you started.

Bilmar’s picture

subscribing

wim leers’s picture

Assigned: Unassigned » wim leers
Status: Postponed (maintainer needs more info) » Closed (fixed)