Closed (fixed)
Project:
Hierarchical Select
Version:
6.x-3.x-dev
Component:
Code
Priority:
Minor
Category:
Support request
Assigned:
Reporter:
Created:
23 Nov 2009 at 09:28 UTC
Updated:
28 Feb 2010 at 19:00 UTC
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
Comment #1
cleverhoods commentedComment #2
wim leersThe 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.
Comment #3
Bilmar commentedsubscribing
Comment #4
wim leersIssue for the documentation: #676990: Document usage of Small Hierarchy module properly.