function theme_hierarchical_select_selection_as_lineages in Hierarchical Select 5.3
Same name and namespace in other branches
- 6.3 includes/theme.inc \theme_hierarchical_select_selection_as_lineages()
- 7.3 includes/theme.inc \theme_hierarchical_select_selection_as_lineages()
Themeing function to render a selection (of items) according to a given Hierarchical Select configuration as one or more lineages.
Parameters
$selection: A selection of items of a hierarchy.
$config: A config array with at least the following settings:
- module
- save_lineage
- params
File
- ./
hierarchical_select.module, line 2438 - This module defines the "hierarchical_select" form element, which is a greatly enhanced way for letting the user select items in a hierarchy.
Code
function theme_hierarchical_select_selection_as_lineages($selection, $config) {
$output = '';
$selection = !is_array($selection) ? array(
$selection,
) : $selection;
// Generate a dropbox out of the selection. This will automatically
// calculate all lineages for us.
$selection = array_keys($selection);
$dropbox = _hierarchical_select_dropbox_generate($config, $selection);
// Actual formatting.
foreach ($dropbox->lineages as $id => $lineage) {
if ($id > 0) {
$output .= '<br />';
}
$items = array();
foreach ($lineage as $level => $item) {
$items[] = $item['label'];
}
$output .= implode('<span class="hierarchical-select-item-separator">›</span>', $items);
}
// Add the CSS.
drupal_add_css(drupal_get_path('module', 'hierarchical_select') . '/hierarchical_select.css');
return $output;
}