Byline Taxonomy

firstamendrulez's picture

After trying CCK for our bylines, I decided to make a taxonomy term for authors instead. I want readers to be able to click on bylines that lead to a taxonomy page with all of the author's published stories.

My set-up looks something like this:

<?php if ($node->taxonomy[xx]) { ?>

<p class="byline">
By <a href=""><?php print $node->taxonomy[xx]->name ?></a>

<?php } ?>

However, I have to add that snippet in my node-type.tpl.php file for each author I have in the system. I also added custom email links and titles (contributor) on some authors. I manually type those in.

What do you think? Does the job doesn't it?


No ....

yelvington's picture

No need to hard-code. Let's imagine your author taxonomy has a taxonomy ID of "6." Get all the author terms like so:

    $byterms = taxonomy_node_get_terms_by_vocabulary($node, 6);

Now you have all the authors (note that there could be more than one). Iterate over the result set. Something like this:

    foreach($byterms as $by)
      if ($i == 0) print 'By ';
      else if ($i == count($byterms) -1) print ' and ';
      else  print ', ';
      print l($by->name, 'taxonomy/term/' . $by->tid);

This supports "By Fred Flintstone, Barney Rubble and Mr. Slate" with each name appropriately linked. Also, if the paths are aliased, l() will take care of that for you.

How does my syntax look?  

firstamendrulez's picture

This works very well! Thank you for your help :)

Using Taxonomy bylines with Field_collection module?

aendrew's picture

I really like this idea and am trying to use it for a Drupal 7 site I'm building.

However, I need more detail than simply the name of the author; each has either a position (I.e., "Ændrew, Production Editor", for bylines) or an organization ("A. Photographer / Newswire", for photo credits). Thus I'm trying to use Field-Collection ( to attach those extra text fields to each taxonomy term (in addition to an image and a caption in the case of a photo).

Everything works as it should, until I try to view the taxonomy term. Because I've attached it to the Field-Collection (The name of which bothers me to no end; I have a weird mental twitch each time I see it due to imagining it as a hyphenated word instead of merely a programming naming convention, but that's neither here nor there), nothing I've associated it with shows up and I get a "There is currently no content classified with this term." message.

Ideally it would link to the relevant story node (when used as a byline) and to the relevant photo (when used as a photo credit). I suppose I could just do this using CCK text fields and views, but using taxonomy seems more organized and less maintenance (Plus gives the ability to use an autocomplete widget, which is nice).

Anyone have any ideas?

ændrew rininsland
news, photos, data, code. :: @aendrew

How to accomplish in views?

akanik's picture

I was wondering if anyone has any advise on how to accomplish this effect with views? I've got my fields printing wonderfully now, but only on nodes.

How can I accomplish the same awesome field print in views?

Thanks so much!

I'm not a complete expert,

firstamendrulez's picture

I'm not a complete expert, but I don't think you would use Views to generate a taxonomy term or custom byline field for an article or blog post. You could, however, use it to display list of bylines.

For example, a list of contributors with their most recent article and mug nested next to to their names (kind of like the way Mother Jones does on their front page) would be one option.

You're best bet would be to create a Panel page (what I do) or Content Template, using context keywords/body variables to generate the fields/terms of your choice. Hope this helps, assuming that you, or anyone else interested, are still following this discussion.

Newspapers on Drupal

Group organizers

Group categories

Topics - Newspaper on Drupal

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: