-
-
Save rupertj/4170387 to your computer and use it in GitHub Desktop.
merge two items to be rendered in item_list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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