Skip to content

Instantly share code, notes, and snippets.

@rupertj
Forked from waako/merge item_list items.php
Created November 29, 2012 17:00
Show Gist options
  • Save rupertj/4170387 to your computer and use it in GitHub Desktop.
Save rupertj/4170387 to your computer and use it in GitHub Desktop.
merge two items to be rendered in item_list
$variables['planning'] = array(
'#theme' => 'item_list',
'#items' => array(),
'#attributes' => array(
'class' => 'icons-info unstyled floated',
)
);
$all_terms = array_merge($variables['field_bbcgf_planning'], $variables['field_bbcgf_diet'], $variables['field_bbcgf_healthy']);
$easily_doubled_key = null;
$easily_halved_key = null;
foreach ($all_terms as $key => $term) {
// Two values that need to be merged into one item
if ($term['taxonomy_term']->name == 'Easily doubled') {
$easily_doubled_key = $key;
} else if ($term_name == 'Easily halved') {
$easily_halved_key = $key;
}
$variables['planning']['#items'][$key] = array(
'data' => t('<i class="icon-small icon-' . $term_css . '"></i>' . $term_name),
'class' => array('class' => $term_css,),
);
}
if ($easily_doubled_key && $easily_halved_key) {
$term_name = t('Easily doubled<br/>Easily halved');
$variables['planning']['#items'][$easily_doubled_key] = array(
'data' => t('<i class="icon-small icon-' . $term_css . '"></i>' . $term_name),
'class' => array('class' => $term_css,),
);
unset($variables['planning']['#items'][$easily_halved_key];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment