Author. Each writer or columnist is represented by an Author node. Author nodes are different than Drupal users because, typically, a writer delivers a story to an editor but the editor actually creates the Drupal node for it; however, it is the Author's name that should appear in the byline. Each Article may reference one or more Authors. New York Observer - a newspaper site

The New York Observer seems to have handled this nicely. My question is how?

I understand creating a content type 'author' and then using the title for a name and then using CCK node reference to link back to the 'author node' within a CCK article-node-type as a field_byline. But how to display a list of article-node-types that have that node reference when viewing the 'author node'? A view? Php?

So how to:

1) Display a list of associated articles when viewing the author node.
2) Make a flat comma-separated list for multiple authors. (Written by W, X, Y & Z)

dewolfe001 asked this question here and no answer... other than "It looks like just a view on CCK data."

Thoughts are most appreciated. Thanks

Comments

level02’s picture

The Rake Magazine has also accomplished the author node very nicely.

I figured out a way to do this with CCK taxonomy but the result is not very elegant. And results in just the normal taxonomy/term view.

And as for the flat comma separated list, using the first-child, and last-child CSS psuedo class' works for FF but not for IE.

level02’s picture

Here is a start: (from The Rake Magazine Drupal showcase thread)

ronan said:

The fields on the nodes are simply First Name, Last Name, Bio and Image. Articles have an Author node reference field as your thread describes.

The Author article listings are created by a view which is embedded in the tpl file for the Author node type. The view has an argument for the Author node reference, and the Author's nid is passed into the views_build_view function when it is embedded:

in node-author.tpl.php:

<div class="author-nodes">
  <?php echo _rake_get_authors_nodes( $nid ); ?>
</div>

in my custom module (can be placed in template.php):

<?php
function _rake_get_authors_nodes( $author_id ) {
  $view = views_load_view( 'authors_nodes' );
  $out = views_build_view( 'embed', $view, array( $author_id ), true, $view->nodes_per_block );
  return $out;
}
?>
TheSponge’s picture

Hello guy !

I'm trying, like you, to have severals authors for 1 node, but I have some problems to do that. Did you make that possible for you ?

I hope you will give me some informations to do that.

Thanks

Bob

P.S : I'm sorry for my English skill, it is not my native language...

Roi Danton’s picture

Thanks for discovering the approach Rake Magazin did. Another approach would include the use of "user reference" with multiple values selected (#2 could be realized this way). Maybe for #1 there are modules which modifiy the display of user profiles.

level02’s picture

The idea for an Author Node (CCK type) is to separate authors from users. For a publication most authors are not users of the site and have nothing to do with the creation of the node. There is a Drupal group profiles-as-nodes that is "very much interested in using nodes for profiles". Author Nodes are similar, accept "very much interested in using nodes for authors".

For example, with multiple values selected for 'node reference' in my CCK field 'byline' for my Article CCK type, mentioned above, I can get:

by Author One Author Two Author Three Author Four

or

by Author One, Author Two, Author Three, Author Four,

or

by , Author One, Author Two, Author Three, Author Four

But what would be nice is:

by Author One, Author Two, Author Three & Author Four

A workaround is to create an Author Node titled Author One, Author Two, Author Three & Author Four. This works but is not ideal. Is there a php way to make a flat comma separated list with an ' & ' before the last node reference?

The functions views_build_view and views_load_view are what do the magic in template.php to display a list of Articles associated with that Author when viewing the Author node. (#1)

For the comment about #1, there are modules that modify the display of user profiles, but the above solution is simple and doesn't require additional modules, or permission checks, etc. Only 10 lines of code + a view + a CCK type.

For the comment about #2, I've tried using 'user reference' and it doesn't work for me. I don't think the CCK field 'user reference' makes a properly punctuated (flat comma separated list) but if it does, then it's worth checking out the code, thanks.

And thanks again to ronan for a solution to #1.