How to show tags, taxonomy, for story content type

Events happening in the community are now at Drupal community events on www.drupal.org.
BDS's picture

All, I must be missing some basic steps: I can't show the taxonomy on my story content type. What has been done:

  1. created taxonomy vocabulary, "tags";
  2. applied to content type "story";
  3. able to enter tags under edit mode; and,
  4. story renders, but tags not showing up.

Is there a setting somewhere?

Thanks!

Comments

depends on what themes /

timgilmour's picture

depends on what themes / modules you're using.

yep. logged in to say just

mike stewart's picture

yep. logged in to say just that. try another theme, or try customizing the theme. be sure to check out: http://drupal.org/documentation/theme

also, in the future, be sure to list version of Drupal you are talking about... and sometimes, the version of any relevant contributed modules

--
mike stewart { twitter: @MediaDoneRight | IRC nick: mike stewart }

Tim, 1) I'm using a custom

BDS's picture

Tim,

1) I'm using a custom theme, do I need to add something like 'show taxonomy' in the .info file?

2) In my node.tpl.php, this code is defaulted there:

<?php
if ($terms):
?>

<?php
endif
?>

3) I looked at the theme setting, but couldn't find this screenshot to customize the taxonomy display: http://drupal.org/files/issues/theme-settings_0.png.
3.1) This is from this discussion, http://drupal.org/node/315569 (I'm not using the beautiful theme).

Any guidance?

well based on the code you've

timgilmour's picture

well based on the code you've posted, looks like you're not printing the terms. that codeblock should be more like this:

<?php
if ($terms): print $terms; endif;
?>

Tim, that did it--thanks a

BDS's picture

Tim, that did it--thanks a lot!

May you expand on this; that to output the taxonomy, it's done at the node.tpl.php level and not at a higher GUI (am I missing this interface / module)? Running D6.

$terms is the object that

timgilmour's picture

$terms is the object that contains all the taxonomy terms for the currently loaded $node object, which is the reason it's in node.tpl.php -- plus the display is usually in the node template to begin with. you can access it from other places (i believe you can get it from page.tpl.php also), but 99% of the time you'll use it in node.tpl.php Not sure what you mean by a "higher GUI", though you're prolly talking about different application layers (or something like that :P).

taxonomy.module provides all that stuff, and it's core. no idea why anyone would not want that active, and i've never seen it disabled, though it's Core (Optional) so you could. i'd go install devel.module - www.drupal.org/projects/devel if you want to go looking at the various objects and their contents using dsm() or other functions. you can explore all the array contents with those.

Tim & Mike - thanks again for

BDS's picture

Tim & Mike - thanks again for this. I wanted to place a comma after each terms and discovered additional tinkering was needed:

Placed this code in the "template.php" file, under the function phptemplate_preprocess_node:

if (module_exists('taxonomy')) {
$term_links = array();
foreach ($vars['node']->taxonomy as $term) {
$term_links[] = l($term->name, 'taxonomy/term/' . $term->tid,
array(
'attributes' => array(
'title' => $term->description
)));
}
$vars['node_terms'] = implode(', ', $term_links);
}

On "node.tpl.php," printed $node_terms.

Is this the direction / path or am I missing a basic helper module for customizing the display of taxonomy because...

What's next, I want to fine-tune the display order by having it appear below the story's title versus above the title ($content). Any suggestions?

Btw, have a great weekend &, again, many thanks!

well again, depends on the

timgilmour's picture

well again, depends on the theme you're using, how its divs are structured, etc. personally, we've standardized on Jeff Burnz's excellent AdaptiveTheme - www.drupal.org/project/adaptivetheme - since it rocks and Jeff is a good guy. In that one, the theme functions itself will let you specify a lot of the $terms output stuff that you're dealing with here, including separators, etc. That theme itself saves us a ton of work, and let us jettison the mangled mess of custom code that we used for ages (template.php stuffs). there's undoubtedly a module or two out there that will do similar things.

Not sure what you mean by "...having it appear below the story's title versus above the title ($content)" -- $content is the node object content output var, $terms is separate from that, and the H1 for the page title is separate (in terms of it's output) also, that usually occurs in page.tpl.php, so really all you need to do is move whatever code outputs $terms to where you want it in the div structure of node.tpl.php. We generally place $terms under the H1 ourselves, having it at the bottom of a node isn't all that useful -- tags should be easily accessible at the top of the page (IMHO).