Hey all. I am setting up categories using the taxonomy module in the Drupal core.

What I would like to do is have a description on each term page. For example, if someone views a page for a term (taxonomy/term/2), it'd display something like:

Term Name
Term Description
Listing of Nodes with this Term

Additionally, I need to be able to set permissions for editing the description for the term. That is, the administrator can give edit and revision permissions for the term description.

Any idea of how I can accomplish this? I'm open to any suggestions.

Comments

NancyDru’s picture

1) There are several snippets of code out here that would do that (also on my site), and I know someone is going to come along and tell you to use Views.

2) That's going to require a module, and probably a new table.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

prattboy’s picture

I can see how I would create a node for each term description and then in turn create a block-level view that displays only the entries for that term... but that adds a couple extra steps to the process. Any relationship between the description and the terms would be artificial, however, wouldn't it?

Or maybe I'm coming at this all wrong. Is there a way to create a node, create a term from within that node, and attach a view that is dynamically generated based on the term that's created within the node?

prattboy’s picture

I think I'm on the right track. I've used the NAT module (http://drupal.org/project/nat) to create a term that's the same as the title of a node of a particular content type when a new node is created.

Now I suspect I can insert a view into the template for the particular content type, but there needs to be a variable. I need a view that displays all entries tagged with a particular term where the term name is the same as the node's title. Can someone point me in the right direction?

NancyDru’s picture

You don't need another module. The taxonomy module already allows you to have a description for each term. The only problem is that it doesn't display when you do "taxonomy/term/xxx" which does all the rest of what you want on your display. There are examples on this site of how to code a Views display that would add that. [Personally I wouldn't even do that, the code for doing this is very simple.]

The difficult thing you want is allowing people to change the description. I'm assuming you, for what ever reason, don't want to grant the appropriate permission to anyone else. You can, however, code a fairly simple module that would show a form allowing anyone to change the description, and it would allow you to assign that permission to a specific role. This would not be hard.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

prattboy’s picture

Alrighty... to get more specific:

Administrator: can create taxonomy terms
Editor: can alter the description of each term; revision control is a must to simulate a wiki-like setting. The revision control portion of it is necessary and leads me to believe that it'd be far more work to recode a module that already does something that the Drupal core does (and does quite well).

At this point, it's possible for me to create a term, create a new node, and put a view in a block on that node that adds that term. But that's three steps. It'd accomplish what I'd want, but it can become a lengthy process for the administrator, considering there are well over anticipated terms that need to be added at the outset of the site. Workable? Yes. Convenient? not really.

With the NAT module, I can at least combine the first two steps. I can edit the template to insert a view into the page, and I'm fairly certain I can pass an argument that will list all the nodes of a particular term. Assume that the page title of the page the user visits will is the same as the term that needs to be passed in the argument (since that's how NAT creates a page).

anneeasterling’s picture

.... for displaying the description? I've searched around and so far haven't found it. Nancy, I'll keep looking but I thought I'd ask in case you happen to be hanging around and can post a link.

Happy day,
Anne

NancyDru’s picture

anneeasterling’s picture

Nope, none of them seem to be for displaying descriptions. Just for counts and lists of terms.

I'll keep looking...
Anne

NancyDru’s picture

All four of them show the description, but in my examples, the description is a URL.

You may also want to look at Vocabulary Permissions.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

anneeasterling’s picture

Thanks, Nancy. I think we've reached a point where my limited knowledge of the coding is keeping me from seeing how to make it work. :-P

(And I'm not looking for anything about permissions and taxonomy. I just want the Vocabulary and Term descriptions to display on the ... I think the right term is category pages. I found this thread while searching for help.)

NancyDru’s picture

If you mean the Admin >> Content >> Categories page, no you're out of luck there. That's a core Drupal thing and unless you can convince the Drupal developers to change it, it won't happen. And Drupal 6 is already frozen for new features, so the earliest you would see it is D7.

As for my snippets, I made some changes just this morning that should make the output look a bit more like real examples. Perhaps if you revisit http://nanwich.info/content_count_taxonomy_term_pager or http://nanwich.info/taxonomy/directory you'll see something more like what you're looking for.

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

anneeasterling’s picture

At least for my issue... and that is displaying the vocabulary and term descriptions. The Taxonomy Context module will do this. I'm working on styling so that it looks better, but it will accomplish what I need and enable me to stop using the very buggy Category module.

Sorry that it doesn't help with the OP's question about editing the taxonomy descriptions.

Happy day,
Anne

Aero-1’s picture

Drupal 6? :(

Island Usurper’s picture

The taxonomy module already allows for descriptions of terms. The trick is getting them displayed in the place you want. They also aren't versioned, so you'll definitely need a new module to keep track of all the revisions, as well as getting the descriptions to show up.

-----
Übercart -- One cart to rule them all.

bermin’s picture

Yes, that is the way I am doing it on a similar site.

I am noticing a problem though. Using drupal 5.2, I have enabled tinymce for the description of the new term. When I use views to display the term description, it isn't recognizing the html. Instead it is displaying the html code instead of the result. My input filters are set properly to allow html markup and it works properly on other node types, just not taxonomy term descriptions using Views.

Anyone?

bermin’s picture

Figured it out. I used the nat body in views instead, seeing that it is the same as the created taxonomy description.

mooffie’s picture

You don't have to use a contributed module, not even Views:

1. Define a new content type, e.g. 'termdef', which will hold a term description.
2. Make it sticky by default (this will put it at the top of /taxonomy/term/x pages).
3. Create a new role, 'editor', and assign it to all your editors. Give this role the 'edit/create termdef content' permission.
4. edit 'node-termdef.tpl.php' to your liking (e.g. remove the title link).

solutionsphp’s picture

I would like to output the Term Description in my template.

I use the ConTemplate module to expose variables. It identified:

$node->taxonomy[28]->description

as the variable for my particular Term. But underneath it, there is no value listed, even though I have a value entered for the Term Description. Hmm.

Moving on, I tried to display the Term Description using this:

print $node->taxonomy['#value']->description

But nothing displays.

Can anyone tell me the correct way to output a Term Description?

TIA!

My review of David Mercer's "Drupal: Creating Blogs, Forums, Portals and Community Websites"

mguercio’s picture

Try this:

    $term = (array) taxonomy_get_term($tid); print $term[description]; 
Coupon Code Swap’s picture

Here is a version for adding term description dynamically for a View using Drupal 6:

http://drupal.org/node/276341

wwwoliondorcom’s picture

How to fill term description automatically

Hello,

Do you know how to complete terms pages automatically ?

I mean at least copy the same term word to the description and keywords fields.

Thanks a lot.

NancyDru’s picture

You can use hook_taxonomy to do this.

wwwoliondorcom’s picture

Thank you, i found this

http://api.drupal.org/api/function/hook_taxonomy/6

but have no idea about what I should do ?!

Thanks a lot.