Creating a content type on D6 about short-listed books for a competition. Each entry (book) in the short-list is a node, with fields for book-title, book-description, author-names (multi-value), author images (multi-value).

So in order to create the short-list I'm using views. I thought I could combine multi-value fields using Views 2 but I can't work out how. I wanted to show:

  • Book title
  • Book description
  • Author photo 1 [image]
  • Author name 1 [caption]
  • Author photo 2 [image]
  • Author name 2 [caption]
  • ...


How can I achieve this using Views 2 on D6?

  • have you tried using a node row style instead of field row style? If you picked teaser view instead of full node it might automagically do what you want.
    – Jimajamma
    Commented Jul 24, 2012 at 16:42
  • @Jimajamma teaser view doesn't display the fields like that. It shows all the photos first, and then all the names which is not what I want.
    – Beebee
    Commented Jul 25, 2012 at 8:22

1 Answer 1


Ah. I gotcha now. Drupal has no internal automagic way of knowing any connection between your author name and photo fields. But, for display purposes at least, you can show them together by hacking at the CCK field template.

If you go into CCK module's directory, you will find a content-field.tpl.php file. Copy it into your theme's directory and then COPY it to content-field-field_author_photo.tpl.php, eg, based upon the field name of your author's photo field name. It is imperative that you COPY it, not just rename it, CCK needs both the base template and the specific field one.

By default, this bad boy looks like this:

<?php if (!$field_empty) : ?>
<div class="field field-type-<?php print $field_type_css ?> field-<?php print $field_name_css ?>">
  <?php if ($label_display == 'above') : ?>
    <div class="field-label"><?php print t($label) ?>:&nbsp;</div>
  <?php endif;?>
  <div class="field-items">
    <?php $count = 1;
    foreach ($items as $delta => $item) :
      if (!$item['empty']) : ?>
        <div class="field-item <?php print ($count % 2 ? 'odd' : 'even') ?>">
          <?php if ($label_display == 'inline') { ?>
            <div class="field-label-inline<?php print($delta ? '' : '-first')?>">
              <?php print t($label) ?>:&nbsp;</div>
          <?php } ?>
          <?php print $item['view'] ?>
      <?php $count++;
<?php endif; ?>

and basically it wraps a CCK content field with lots of CSSable divs and so forth. What you want to do is print out the author name under each photo, so you could do that by replacing the print $item['view'] (which is your photo) with something along the lines of this:

          <?php print $item['view']; ?>
          <?php if (!empty($node->field_author_name[$delta]['value']): ?>
             <div class="author-photo-caption">
               <?php print check_plain($node->field_author_name[$delta]['value']); ?>
          <?php endif; ?>

And now when CCK builds this field, it will also grab the author name and put it under the photo. It will of course still build the author name field and display it, so if that's not what you want, you can go in the Display Fields section of the node type config and exclude it from the $content variable and then it will only show up here.

Clear caches/theme registry and style up the author-photo-caption class and you should be set. And now wherever this field is displayed, it will grab its counterpart (assuming no typos above :)

(Other assumptions: field_author_photo and field_author_name are the names of your fields on your system.)

  • +1 for detailed answer, thanks a lot. Now with this I can use Display Suite to show the nodes through Views.
    – Beebee
    Commented Jul 25, 2012 at 14:34
  • Quite welcome. This drupal.stackexchange.com/questions/36597/… might help out, too, if you don't even want the author_name field and instead want to use the photo description field.
    – Jimajamma
    Commented Jul 25, 2012 at 14:38

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.