Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This simple block snippet displays a list of taxonomy terms without description in alphabetical order. Each term links to the corresponding term's edit form.
This is useful for example when you use the Taxonomy context module (http://drupal.org/project/taxonomy_context) and display descriptions of terms on the term listings pages.
<?php
/**
* Creates a list of taxonomy terms without description in alphabetical order.
* Each term links to the corresponding edit form.
*/
$query = "SELECT tid, name from {term_data} WHERE description = '' ORDER BY name ASC";
$result = db_query($query);
while ($term = db_fetch_object($result)) {
$items[]= l($term->name, "admin/content/taxonomy/edit/term/$term->tid");
}
if(count($items)) {
return theme('item_list',$items);
}
?>
Note: In Drupal 4.7 the URL in the l() function should be "admin/taxonomy/edit/term/$term->tid"
instead.
Comments
I am using a slight
I am using a slight modification of this snippet:
It generates what i am after in a UL, though i have yet to work out how to generate the UL to have .first and .last classes (like other drupal generated lists). The aim is to improve CSS customisation.
Any one have a solution? I have tried to incorporate a call to the theme_links function, with no success.
avolve designs | ethical by design
This is great
This code is very helpful to me. Thanks.