I have two fields displaying multiple values from select lists. The first field's a term reference field, the second's a text list. So,
print render($content['field_term_list']) produces
- Term1
- Term2
and print render($content['field_text_list']) produces
- Text-item1
- Text-item2
I'd like to merge the output into a single list, preferably sorted alphabetically, and print it from a new variable:
<?php print ($combined_lists); ?>
- Term1
- Text-item1
- Term2
- Text-item2
How can this be done using theme_preprocess_node?
$content['field_XXXX_list']
. They are "render arrays" and contain all the information in more or less raw form thatrender()
then creates the HTML out of. Craft/sort/do whatever you want with them both in yourpreprocess_node()
hook and assign that to a variable and you'll be all set.