Hi,

I need to show a completelly diferent taxonomy page for specific terms.
Any idea how can I override the default function, vy theming it or other way?

Regards,
Fernando Silva

Comments

nellus’s picture

pembeci’s picture

My theme (civicspace) is adding to the body element a class like page-taxonomy-term-8 which can be used to theme a specific term page by using CSS:

body.page-taxonomy-term-8 {
  background : green;
}

will make that term page's background green for instance.

There is no direct way changing the content of the page though if that's what you need. You have to modifye some code. If you are familiar with PHP and how Drupal works, you may try changing the taxonomy_term_page function:

http://drupaldocs.org/api/4.6/function/taxonomy_term_page

You have to change how $output is constructed before print theme('page', $output); is called based on $current->tid.

An easier way may be changing your page.tpl.php if you are using a PHPTemplate theme. You can check if you are at a taxonomy term page with smt like:

if (arg(0)=="taxonomy" && arg(1)=="term" && is_numeric(arg(2))) {
  switch(arg(2)) {
  case 3: ...
  case 7: ...
  default: ...
  }
}

arg(2) will give you the term id when the path of the page is smt like taxonomy/term/12. If you tell more how you want to change it, people can suggest other things too.

magico’s picture

Hi,

The problem about the current taxonomy page view is that is too "basic". It does not have any function that allow us to construct diferent styles of data output.

For example, when you have "taxonomy/term/8" it will show all nodes from that term in a list. While I'm trying to construct a list of another kind:
- children term of term (8)
--- nodes list
- children term of term (8)
--- nodes list
- children term of term (8)
--- nodes list

And the only thing I need is just an API from taxonomy that could hook the taxonomy_term_page and change the output of it. What do you think?

pembeci’s picture

"taxonomy/term/8/all" will show you all the nodes from term 8 and its all subterms. Instead of this you can say "taxonomy/term/8/2" and it will show nodes from subterms and their subterms but not going deeper. So that argument is the depth of the subtree.

However these nodes will be ordered by time not by subterm as you want. To do that, yes, you have to write your own module or modify taxonomy_term_page. You can check taxonomy_dhtml module or other taxonomy related modules to see how they construct blocks or pages similar to what you want.

Check also the PHP page snippets:
http://drupal.org/node/23220

Good luck.

venkat-rk’s picture

This may be what you are looking for:
http://drupal.org/node/46027

magico’s picture

Well, I end up by creating a new module that creates a special formated list of nodes from a specific taxonomy term.

daflow’s picture

Hi there magico,

A few weeks ago i was searching for a solution for the same problem. After a lot of searching, i came up with following solution. Like you, I wrote my own module which gives back the nodes based on a certain term id. Then i used the taxonomy_redirect module to redirect a certain taxonomy to the custom module url. I must say, this works great. I got full layout-control on the output of my custom module. And yet i can use the internal taxonomy links (like in a node) in drupal.

I hope the taxonomy_redirect tip can be an addition to your solution.

Greetz

daflow

magico’s picture

Thanks! I'll take a better look into taxonomy_redirect :)

reikiman’s picture