Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Assuming that the example you've given works to output the first author, the most direct solution to get all the authors in a comma-sperated list would be the following:</p> <pre><code>foreach($node-&gt;field_author as $author) { $authors[] = $author[view]; } $author_list = implode(', ', $authors); </code></pre> <p>Then you'd output <code>$author_list</code> in place of <code>$node-&gt;field_author[0][view]</code></p> <p>A more "Drupal" way of doing it would be to copy modules/cck/theme/content-field.tpl.php to your theme directory, then make a copy of it named <strong>content-field-field_author.tpl.php</strong> as well. You can then make changes to the new file which would override how the values are displayed for the "author" field specifically. Then you could output themed field_author value wherever you want in a custom node-[node_type].tpl.php file. (You may need to clear cached data via the button on <strong><em>Administer > Site configuration > Performance</em></strong> for the custom templates to be loaded the first time.)</p> <p>If your view's "Row style" is set to "Node" then it will use the node and field templates as well. If you have it set to "Fields" then you'll need to theme the field in the view separately. See your view's "Theme: Information" for views templates you can override in your theme.</p> <p><em>Edit:</em><br> Missed the fact that you wanted a natural language list. That takes a bit more, but here's a Drupalized function that will do just that:</p> <pre><code>function implode_language($array = array()) { $language_string = ''; if (count($array)) { // get the last element $last = array_pop($array); // create a natural language list of elements if there are more than one if (count($array)) { $language_string = implode(', ', $array) .' '. t('and') .' '. $last; } else { $language_string = $last; } } return $language_string; } </code></pre> <p>Then, of course, use the following in place of the last line my first code block above:<br> <code>$author_list = implode_language($authors);</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload