I'm trying to output a single piece of text from a multi-value text field (unlimited # of values) in my node template and I can't for the life of me figure out how to do it AND apply the THEME to it.

If I just do this:


I get the plain old markup for the field. However I want it to be run through the filters and have the theme template applied to it just as if I were rendering the full field with all the values like so:


I've tinkered with passing the #theme values and other vars to the array and using the theme() function also. but I can't quite seem to get it. What am I missing?

1 Answer 1


It seems like there are properties in $content['field_hero_slideshow_header_text'] which determine how it's themed. Perhaps a '#theme'.

Can you try making a copy of the entire field with just the value you want?

$content['field_hero_slideshow_header_text_copy'] = $content['field_hero_slideshow_header_text'];

// Unset all multi values, they have integer keys.
foreach($content['field_hero_slideshow_header_text_copy'] as $k => $v) {
  if (is_int($k)) { unset($content['field_hero_slideshow_header_text_copy'][$k]; }

// Add just the one we want back in.
$content['field_hero_slideshow_header_text_copy'][0] = $content['field_hero_slideshow_header_text'][0];

// Output single field.

// Do you need to remove the field from the original array?

Not the nicest way I know. You could try copying properties from the parent to the child and it might output correctly, though I don't think so because the theme function probably expects data in a parent > child format.

  • Yes!!! It was the copying and unsetting that I was missing. I was trying to work directly with the original copy of the array rather than copying it first. Doesn't look like unsetting the field from the original array was necessary for my application. Thx!
    – Pooch
    Commented Feb 18, 2014 at 22:53

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.