University of Oregon

Drupal 7 – list taxonomy terms

I’m running some tests and thought I’d post the php code to display the terms for a taxonomy:

$terms = taxonomy_get_tree(taxonomy_vocabulary_machine_name_load('temp_auth_temp_agency')->vid);
if ($terms) {
  foreach ($terms as $term) {
    $options[$term->tid] = str_repeat('-', $term->depth) . $term->name;
echo '<pre>$options: '. print_r($options,true) . '</pre>';

/* Returns:
$options: Array
    [439] => DePaul
    [441] => Express
    [440] => Galt Foundation
    [442] => Kelly Services
    [443] => Manpower
    [444] => Personnel Source

At the moment I’m considering leveraging the benefits of CCK Select Other for ease of entry with taxonomies for term management. Not sure if it’ll be worth it but this was an interesting code hunt.

Drupal 6 How to put taxonomy description into taxonomy views page?

I was wrestling with adding taxonomy term descriptions into list page this today and found this views 2 snippet for a php header to do the trick:

  $description = i18nstrings("taxonomy:term:$term-&gt;tid:description", $term-&gt;description);
else {
  $description = $term-&gt;description;
print $description;

via How to put taxonomy description into taxonomy views page? |

Updated Taxonomy Hierarchy Saving Scheme

I reversed two of the settings in the Hierarchical Select configuration. Now we can assign links to any level, not just the deepest, and we are no longer saving the ancestors of each term.
The new settings for the taxonomy

This should clear up any confusion as to why some links are found in their parent categories and some are not. Every link we created and tagged since we enabled Hierarchical Select has been assigned to the node we choose and the parents as well.
In addition, we no longer need to use the ‘general’ categories as we can assigned links to the parent category directly.

Added a new tool for selecting taxonomy terms

I added a new tool to aid in selecting taxonomy terms.
It appears as a link in a block positioned in the right side bar on edit pages.

Screen shot

A new option is available in the right sidebar: "Suggest keywords" containing one link: Highlight Terms.

Upon clicking the Highlight terms link a script searches the body of the node and does two things:

  1. Highlight taxonomy terms found in the body