Finding Term IDs

The first thing that you need in order to query the taxonomy (category) system is the ID number of the term(s) you are interested in. You'll need to do some sleuthing to find this, but it is not hard to do. Select administer > categories > edit terms to go to the edit page of a vocabulary. There you will see a list of terms as well as an Edit link for each one. The Edit link provides the important clue that you are seeking. Hover your cursor over the link, and the URL to the link will appear in the status bar at the bottom of your browser window (if it doesn't, click the link and it will appear in the navigation bar at the top of your browser window). It should look something like this:

The pertinent part of this URL is the term/4 segment in the middle. That tells you that you are looking at term number 4.

Note The technical term for category in Drupal-speak is taxonomy. The Taxonomy module is responsible for Drupal's category functionality, and the Drupal paths that you will be building to query your site will all start with the word taxonomy. Therefore, this section refers to categories using the technical term, taxonomies.

The term ID (tid) is essential information when building URL-based taxonomy queries, so having an easy way to find them is essential. If you are able to look into your database, you can open the term_data table and use it as a reference. The tid column contains the number you are looking for, and you can see the term's name in the name column.

Once you have a term number in hand, you can build a simple path to view all of the content that is tagged or categorized with that term. The form of the path is taxonomy/term/ tid, where tid is the term ID number. Here is an example using the tid 4 with clean URLs:

And here is an example without clean URLs:

0 0

Post a comment