Proper usage of Taxonomy in Themes

auxone - November 28, 2008 - 17:01

I'm fairly new to Drupal, but I've been reading a lot. Can someone tell me if this idea will work?

I've come to the conclusion that the best way to organize and display my content is through Taxonomy. Basically, I want my site to have a simple hierarchy of terms, each major term is a distinct page of my site and each minor term is content that will appear in a specific area on that page. I am doing this because I need multiple nodes to be loaded on a single page so I may display them in separate chunks on my site.

It's my understanding that I can just theme the node.tpl.php to strip each node down to just its body text, which is all I want. And I can theme page.tpl.php to detect which term the nodes on the page are using. However, I am having trouble conceptualizing how I would proceed -- would I have to make all my pages themes like page-taxonomytermhere.tpl.php? Or would I have to make all my links point to taxonomy/term/{tid}, where each tid is a major term and thus a page of my site?

I'm not sure how to theme a taxonomy/term/ page, I assume it's a matter of just themeing page.tpl.php then check the terms associated with the node on the page?

Does what I am saying sound like it will work? My only problem is when I view a major term, the terms that are hierarchically beneath it (minor terms) don't appear on the page. How can I get all minor terms that are under a major one?

Thanks, and sorry for the long post! Sometimes just writing the post helps me tons.

=-=

VeryMisunderstood - November 28, 2008 - 17:07

I think you want to investigate the views.module which will extend the way you can create lists.

I think it is also important to realize that a vocabulary is a container, the terms are the categories in taxonomy. That said:

When you create a new term, Drupal assigns it a number. And you can call up all the items categorized under that term by calling for its number.
To see your term's number, go to the categories page, choose list terms for the category to which your term belongs, and now hover over your term's name in the list. You'll see the number.

If the term "sonatas" is term 1, this would call for all the nodes of that category.

If the term "Bach" is term 2, this could call for only those sonatas written by Bach:

taxonomy/term/1,2

Or if Brahms is term 3 and this will call for everything that has to do with either Bach or Brahms:

taxonomy/term/2+3

If you are using a hierarchical taxonomy, and want all notes tagged with child terms to show up also, you can create an URL link like taxonomy/term/2/2 where the second parameter is the depth that the tree will be recursed into, or taxonomy/term/2/all for all child terms.

The above quoted from: http://drupal.org/handbook/modules/taxonomy

Besides views you probably

nevets - November 28, 2008 - 17:43

Besides views you probably want to look at the panels module which lets you build pages up from other Drupal content include nodes, views and blocks. The way you have suggests seems to subvert the power of Drupal

Thanks guys.

auxone - November 28, 2008 - 18:57

I appreciate the guidance from both of you. Nevets, you've commented on a previous post of mine which lead me down the road to taxonomy in the first place. Thanks again for this post as well. I did look into Views but I must admit I was a little intimidated. In fact, I still am! And frankly I still have no sense of what subverts Drupal or not.

=-=

VeryMisunderstood - November 28, 2008 - 19:01

Views.module doesn't subvert drupal. It's one of the powerful modules provided by a very good developer. IT is also very widely used in the community and on some major sites.

You initial post suggests

nevets - November 28, 2008 - 20:00

You initial post suggests you are using the theme files to make content decisions which really not the place to have such logic. For more than viewing a single node on a page, views provides a host of ways to list content on a page. Want a more "random" selection of content, consider adding in the node queue module. Want more than just a list, look at the panels module. These and other modules allow you to build pages of nodes and more.

Taxonomy which comes with core provides and easy way to categorize content and provides pages at taxonomy/term/{tid} listing all content tagged with the term with the term id specified with {tid}

 
 

Drupal is a registered trademark of Dries Buytaert.