Hi, all.

I'd like to change the way teasers look when you view each taxonomy term. Is this possible? Specifically, I'd like to get rid of the term underneath the node title. I'd like the option to get rid of the teaser text as well, though I haven't decided whether I'm going to do that yet.

Yes, I do have Views installed, but I don't really want to go through the trouble of creating a View for every single taxonomy term. I already have three or four custom vocabularies, some with twelve terms per vocabulary, and setting up a separate view for each seems really wasteful, not to mention time-consuming should I choose to add more terms or vocabularies down the road.

Is there a way to do this from within Drupal's admin system, or would I have to theme a separate node type to do this?

EDIT: I moved this to the Theme forum, since that seems more appropriate.

Comments

adam_b’s picture

Have you tried using arguments in Views? This could allow you to make one view, and then specify the term by either the name or the ID.

Karlheinz’s picture

At the moment, the only way to access different taxonomy terms is through the breadcrumbs (using taxonomy_breadcrumb). But this won't work with Views. I could expose the taxonomy terms, but frankly I don't want to (I hate drop-down lists).

Custom Breadcrumbs might work, but it appears that the functionality I need is only in the 2.x version, which is still in Dev phase. I'd rather not install any Dev packages on my live site.

Besides, other than what I asked about, everything works fine.

Any other ideas? Worse comes to worst, I can hide the fields using CSS visibility, but that seems like a cheat somehow.

EDIT: It looks like I should be able to override theme_taxonomy_term_page() from taxonomy.pages.inc.

-Karlheinz

Karlheinz’s picture

EDIT: It looks like I should be able to override theme_taxonomy_term_page() from taxonomy.pages.inc.

Well, that didn't work.

It looks like theme_taxonomy_term_page() only prints the term description; I could move this around on the page (e.g. print it after the teaser nodes, or omit it altogether), but that's only half the battle.

On each term page, the teaser contains the term itself right under the node title. An example node teaser, with the parts in square brackets:

[node title] One more essay

[teaser text] This is another essay.

I would like to be able to:

  1. Display the taxonomy term below the teaser text
  2. Not show the taxonomy term in the teaser, but show it in a full node
  3. Omit the taxonomy term, if it matches the page title
  4. Omit the taxonomy term altogether

...And I'd like to be able to choose which.

I've looked into the API, but I could not find where to do this. I've also looked through taxonomy.pages.inc and taxonomy.module, but none of those functions seemed to let me do these things. I also cannot find any template suggestions.

theme_taxonomy_term_page() calls a function named taxonomy_render_nodes(), but this just recursively calls node_view() to format its output. It appears that the taxonomy module is inserting its terms directly into $node->content, but I can't figure out how.

Help...?

-Karlheinz

Karlheinz’s picture

Anyone?

To reiterate: I've tried looking in the 6.x theming handbook for template suggestions, but I couldn't find any reference to taxonomy suggestions. Am I just missing something?

-Karlheinz

Karlheinz’s picture

Seriously... Nothing?

This seems amazing to me. I've seen loads of sites where there are no taxonomy terms in the teasers.

This would be easy if there was a template file for node teasers, but AFAIK there isn't. Would Contemplate work for this sort of thing?

-Karlheinz

Karlheinz’s picture

Okay, I finally found the answer.

The code to display the taxonomy terms is in node.tpl.php. I had no idea that this is the template used to create teasers as well, but apparently it is.

I changed this:

<?php if ($terms): ?>
  <div class="terms terms-inline"><?php echo $terms ?></div>
<?php endif;?>

...to this:

<?php if ($terms && !$teaser): ?>
  <div class="terms terms-inline"><?php echo $terms ?></div>
<?php endif;?>

Now, it will not show any taxonomy terms if $teaser is true.

The other stuff I'd like to do can be done in a similar manner.

EDIT: I added a comment to the Core templates and suggestions page. I don't know if this merits a new sub-page, but if so, I'll be happy to add one.

-Karlheinz

newtothegame’s picture

Was trying to do the same thing. Your code & post helped a lot!