Community

D7 can't theme the taxonomy page properly, nodes are being output at the bottom.

Hello,
i've this issue with D7 theming.

I am overriding the tpl suggestion by using
taxonomy-term--VOCABULARY_NAME.tpl.php

The page outputs fine, BUT every node (with $teaser=1 mode) is being output at the bottom of the page, so i cannot fit nodes in my layout. What am i missing?

Here's my tpl

<?php include dirname(__FILE__) . '/includes/taxonomy-header.inc' ?>
<h1><?php print ucfirst($name)?></h1>
<?php //this is the main, left-floated, area ?>
<div id="social_news" class="left">
</div>
<?php //this is some kind of right column ?>
<div id="big_puppet_right" class="left">
  <div id="text_puppet" class="left">
  </div>
</div>
<?php //nodes are being output here, while i want them in the social_news block ?>

Comments

Please try using vocabulary id

Can you please try using the following name for the tpl file

taxonomy-term--VOCABULARY_ID.tpl.php

-Mohit

You mean using vid? I don't

You mean using vid? I don't think this is possible.

taxonomy-term--[vocabulary-machine-name|tid].tpl.php
base template: taxonomy-term.tpl.php
Theme hook suggestions are made based on these factors, listed from the most specific template to the least. Drupal will use the most specific template it finds:

taxonomy-term--tid.tpl.php
taxonomy-term--vocabulary-machine-name.tpl.php
taxonomy-term.tpl.php
Note that underscores in a vocabulary's machine name are replaced by hyphens.

Full topic here: http://drupal.org/node/1089656

Any numeric value put in there would be considered as a TID.

I found out this:

I found out this: http://drupal.org/project/disable_term_node_listings

I find really strange that one should entirely suppress the node listing, and embedding views or blocks. I mean, what would be the point of theming taxonomy page if you can't control the node display?

+1

Wow, there's really no way to tell taxonomy-term.tpl.php to suppress the listings? That's ridiculous.

FWIW, this is how disable_term_node_listings does it:

/**
* Implements hook_menu_alter().
*/
function disable_term_node_listings_menu_alter(&$items) {
  // Take over from the taxonomy module.
  $items['taxonomy/term/%taxonomy_term'] = array(
    'page callback' => 'disable_term_node_listings_term_page',
    'page arguments' => array(2),
    'access arguments' => array('access content'),
  );
}

/**
* Menu callback; displays all nodes associated with a term.
*
* @param object $term
*   The taxonomy term.
*
* @return string
*   The page content.
*/
function disable_term_node_listings_term_page($term) {
  // Check if the term that this vocabulary belongs to has listings disabled.
  $term_list_disabled = variable_get('disable_term_node_listings_' . $term->vocabulary_machine_name, FALSE);

  if ($term_list_disabled) {
    // Set the title and return all the field data.
    drupal_set_title($term->name);
    return taxonomy_term_view($term, 'full');
  }
  else {
    // We have to pull in taxonomy's pages include so we can call its function.
    module_load_include('inc', 'taxonomy', 'taxonomy.pages');
    return taxonomy_term_page($term);
  }
}

—Ændrew Rininsland
Drupal developer by day, data journalist by night
Data journalist by day, Drupal developer by night
http://www.aendrew.com

The part that seems special

The part that seems special is

<?php include dirname(__FILE__) . '/includes/taxonomy-header.inc' ?>

One could make a block that has this functionality, place in the content area and limit the pages it shows on.

As a guess header is a banner image in which case one could add an image field to the vocabularies in question.

I can't get your point, how

I can't get your point, how should this be helpful? I can get rid of the header, or of the entire tpl code, nodes keeps showing automatically and that's what i'm in trouble with.

If the only thing that is

If the only thing that is special/different is the taxonomy header I would not use a tpl.php file, instead I would use a block.

OK, now i got you. No, that's

OK, now i got you. No, that's not the only difference, thank you anyway.

Hello, sorry for bumping this

Hello, sorry for bumping this but im facing the very same question again, and still i can't understand what i'm missing.
This time it is a much easier situation.

  1. I'm working on a clean Bartik theme
  2. I added taxonomy-term.tpl.php
  3. Themed my taxonomy term page, that's ok

Now, below my template, nodes are output. Say

<!-- Here's where taxonomy-term.tpl.php starts -->
<div class='my-awesome-taxonomy-theming'>More HTML code</div>
<!-- / Here's where taxonomy-term.tpl.php ends-->

<!-- Here's where nodes are being output-->

Which tpl is responsible for this to happen? I mean, there should be some
print statement, somewhere, that is causing nodes rendering.

Whats your actual goal here?

Whats your actual goal here?

My goal is theme the

My goal is theme the taxonomy-term template, controlling the microlayout in which nodes are shown.

Edit the node template, I

Edit the node template, I think there is almost a fundamental disconnect in this thread, taxonomy term tpl is for terms. Node teasers appear on taxonomy term list pages, e.g. /taxonomy/term/1 is a list of nodes tagged with term id 1.

I can see how this is confusing, but the taxonomy term template is for the display of a term.

Noted, but I think you're

Noted, but I think you're misinterpreting the problem. If you look at taxonomy-term.tpl.php, the only code there is for theming the term title, description and any fields. The items themselves aren't stored in a themable array or something somewhere -- they're just appended to the end of the term template by taxonomy.module.

This is annoying if, for instance, you have a container and want to wrap each node being listed in a wrapping div or something, which is then wrapped in a column div.

—Ændrew Rininsland
Drupal developer by day, data journalist by night
Data journalist by day, Drupal developer by night
http://www.aendrew.com

Ok Jeff and aendrew, thank

Ok Jeff and aendrew, thank you for gettin my point. Problem is quite there imho, because for Drupal a default taxonomy page is
- the themed taxonomy_term
- the themed related nodes in teaser mode
Period.

What i am talkin about is the possibility of theming the layout in which node teasers are shown, without using view. Isn't strange that we don't have an overridable taxonomy-term-page.tpl? I know we can theme every page as we like, but here i'm talkin about a "native" template as there's one for nodes, terms, etc.

I've created an issue about

I've created an issue about this here: http://drupal.org/node/1920134

—Ændrew Rininsland
Drupal developer by day, data journalist by night
Data journalist by day, Drupal developer by night
http://www.aendrew.com

nobody click here