Drupal Wish #1: Easier Linking to Terms
Posted July 2nd, 2007 by DrupalaceA common newbie question: How do I create a page which, for example, lists all news stories and not other posts?
The proper Drupal response, I believe, requires a small change in mindset. A page that lists nodes (as opposed to a page that simply presents one node) doesn't exist until created on the fly. The proper Drupal question is: How do create a link that returns all news stories?
For anyone not already more well-versed in solutions than I am, here are two ways to do it:
1) Use a specific node type (such as story) for all of your news stories, then use the Views function to create a list of all nodes of that type. Create a menu item linking to that View.
(Views is a rich and wooly topic. Enough on that for now.)
2) Tag all of your news stories with a specific term (like "news"). Create a menu item that returns all nodes tagged with that term. Voila!
The latter is the easier way that I'm most familiar with; I've used it a lot. (For example, the "wishes" link in my primary menu simply returns all nodes tagged with "wish".) And it's not so hard to do. My menu item's link points to "taxonomy/term/34", where 34 is the number Drupal has placed upon my term "wish".
But as you probably know, it's a pain to get that number. You have to go into Categories, click "list terms" for the vocabulary containing your term of interest, and then hover your pointer over the "edit" link for the desired term in the list. See the long URL showing up in your browser's status bar? Parse it for "taxonomy/edit/term/<some number>"; that number is the 'droid you're looking for. Jot down or remember that number; you'll use it when creating the link to that term, as above.
It gets a little worse. Say you haven't even created a term "news" yet. You can't create the menu item now, and later populate your site with stories tagged with a brand-new term "news". You have to first create the term before you can create a link in the menu item.
Yech. For elegance and ease of use, it's a mess of a method that only a Microsoft could be proud of.
Shouldn't there be an easier way? Why can't I call directly upon the term itself in my menu items, such as "taxonomy/term/'news' "? That seems the equivalent of calling upon a term ID# that's uniquely bound to the term word "news", but is far, far easier than going through gyrations to discover the ID#. (The user shouldn't have to care what the ID# is!) And it would allow you to create the menu item first if you wanted (it simply wouldn't return anything until you later did create a term "news").
Am I alone in holding this wish for Drupal?












