0

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?

2
  • What you will want to do is look at what is actually in $content['field_XXXX_list']. They are "render arrays" and contain all the information in more or less raw form that render() then creates the HTML out of. Craft/sort/do whatever you want with them both in your preprocess_node() hook and assign that to a variable and you'll be all set.
    – Jimajamma
    May 1, 2013 at 1:15
  • @Peter Clemence, when you say "combined", you'd want to show them in a new dropdown or say, an item list? May 1, 2013 at 1:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.