function _hs_smallhierarchy_transform_recurse in Hierarchical Select 5.3
Same name and namespace in other branches
- 6.3 modules/hs_smallhierarchy.module \_hs_smallhierarchy_transform_recurse()
- 7.3 modules/hs_smallhierarchy.module \_hs_smallhierarchy_transform_recurse()
Helper function for _hs_smallhierarchy_transform().
@params $parent The parent item of the current level. @params $hs_hierarchy The HS hierarchy. @params $relative_hierarchy The hierarchy relative to the current level. @params $separator The separator to use.
1 call to _hs_smallhierarchy_transform_recurse()
- _hs_smallhierarchy_transform in modules/
hs_smallhierarchy.module - Automatically transform a given hierarchy with this format: array( 'win' => array( 'label' => 'Windows', 'children' => array( 'xp' => array('label' =>…
File
- modules/
hs_smallhierarchy.module, line 203 - Implementation of the Hierarchical Select API that allows one to use a hardcoded hierarchy. When it becomes to slow, you should move the hierarchy into the database and write a proper implementation.
Code
function _hs_smallhierarchy_transform_recurse($parent, &$hs_hierarchy, $relative_hierarchy, $separator = '|') {
foreach ($relative_hierarchy as $item => $children) {
$generated_item = $parent . $separator . $item;
$hs_hierarchy[$parent]['children'][] = $generated_item;
$hs_hierarchy[$generated_item]['label'] = $children['label'];
// Build the subsequent levels.
if (isset($children['children'])) {
_hs_smallhierarchy_transform_recurse($generated_item, $hs_hierarchy, $children['children'], $separator);
}
}
}