Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 627531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:32:20+00:00 2026-05-13T19:32:20+00:00

I have an Author content_type that I’m switching out for username in articles. The

  • 0

I have an Author content_type that I’m switching out for username in articles. The problem is that a story can have multiple authors, and the following code in template.php will only generate the first author. How can I get this to output to be readable as “By John Smith, Jane Doe and Mary Poppins | Feb 19, 2010”?

function mytheme_date($node) {
  return t('By !username | !datetime',
  array(
    '!username' => t($node->field_author[0][view]),
    '!datetime' => t($node->field_publish_date[0][view]),
  ));
}

Please bear in mind that I’m also wanting to use this for views too, so that a node reference will output correctly there too.

Thanks,
Steve

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:32:21+00:00Added an answer on May 13, 2026 at 7:32 pm

    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:

    foreach($node->field_author as $author) {
      $authors[] = $author[view];
    }
    $author_list = implode(', ', $authors);
    

    Then you’d output $author_list in place of $node->field_author[0][view]

    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 content-field-field_author.tpl.php 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 Administer > Site configuration > Performance for the custom templates to be loaded the first time.)

    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.

    Edit:
    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:

    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;
    }
    

    Then, of course, use the following in place of the last line my first code block above:
    $author_list = implode_language($authors);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem, with Zend_PDF multiline, my problem is that I can't write
I have some information in my database like 'author', 'book' etc., that are all
I have the following JSON content that I'm pulling from a service feed: [
Have an issue with the following array... I can't navigate it using $arrayname[0]... it
I have the following code that converts my twitter account rss feed into a
I have some content like this: author = Marjan Mernik and Viljem Zumer, title
I have a model class like this: class Note(models.Model): author = models.ForeignKey(User, related_name='notes') content
As an Actionscript programmer shifting to JS/jQuery I often have to author multipage apps
I have two tables: author (id, first_name, last_name) books (id, title, rate, author_id) and
I have three tables Author, Book and AuthorBook. AuthorBook table only contains two foreign

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.