Been looking all over for this and haven't found any solution.

I'd like to list in one page all terms in one vocabulary (not all nodes in a term or all nodes in terms in a vocabulary). Sort of like a homepage or entry or index to that vocabulary (without listing the other vocabularies or terms in the taxonomy).

I believe others would find this usual, to be able to have a page that lists the many terms in a particular vocabulary.

Here's an example, at http://www.edestiny.net I have 2 vocabularies: one for spanish content, another for english content. I'd like to add a link that says "English" and list all terms (not the nodes) in the English vocabulary (ICT for Human Development).

You can see these 2 vocabularies listed there as blocks in the right column. I just want to be able to put one of these blocks in a page, not on a side bar.

This is not a multilingual feature request for I have the very same need in other site, where you'd rather not mix research terms (categories) with administrative terms (categories) and decide to put them in separate vocabularies.

I'm using taxonomy_list, taxonomy_dhtml, taxonomy_html, taxonomy_browser, site_map and sitemenu modules and they are all great (see them working at http://www.edestiny.net/sitemaps ) but no good for this:

- taxonomy_dhtml, taxonomy_html, site_map and sitemenu build nice maps of all vocabularies and terms, but you can't single out an specific vocabulary to be listed as a parameter (you can configure it though to do so, but then you will only list that vocab and will have no choice of listing any other).

- taxonomy_menu and taxonomy_block will build blocks just the way I want, but I'm not looking for blocks... I'm looking to list the terms in a single vocabulary in a full page.

- vocabulary_list comes close, but list the nodes in the specified vocabulary, not the terms...

Anything done regarding this or should I just program my way into a solution?

It seems like a simple thing to do, so I'm wondering if it's out there as a feature of the core or any module and I'm just not seeing it...

Comments

Carlos Miranda Levy’s picture

Answer to this available at:

Although the text in in Spanish you should be able to read the code :-)

Three methods are listed:

Please note that there is also a module for this at:

with a 4.6 upgrade patch at:

Thanks to:

Carlos Miranda Levy’s picture

Answer to this available at:

Although the text in in Spanish you should be able to read the code :-)

Three methods are listed:

Please note that there is also a module for this at:

with a 4.6 upgrade patch at:

Thanks to:

for their original replies at

------
Con paciencia y calma,
sube un burro a una palma

smilodon’s picture

This guy told you, that "lists" module is not enought for him, u still suggest him that. Its rude.
And the other stuff are non-english, so no fix here.

Im also searching a simple way to display all the terms by voc. on one page.
I DO NOT WANT all nodes in one voc. to be displayed.

kickn’s picture

I would love to know this as well :)

J

venkat-rk’s picture

I think the Views module might be the answer. Create a 'list view' and choose "Taxonomy: Terms for a Particular Vocabulary" as the View Field. Additionally, if you set this view to be created as a page, you will have what you want- a page that lists the terms of a particular vocabulary. See http://drupal.org/node/54448

Note that I haven't done this myself yet. I have been reading the Views documentation and bumped into this post by chance.

greeneo’s picture

Views doesn't quite do it. The problem of making a view for this is it will display a term for every node found with that term. Using the distinct node filter does nothing as the nodes themselves are distinct. They just have the same term, and so if it's a list view with only a field for a term, you get what looks like a bunch of duplicates.

Any other suggestions or thoughts or PHP scripts out there? People really need this functionality and it seems odd that knowledge on it is so scarce.

bgeddes’s picture

I came upon this page when I had the same problem, maybe its fixed elsewhere, if not here is what I did.

Create a view list with the filter set to terms for category like venkat-rk said, theme the views with the theme wizard and it wil give you some code to append to your template.php file and two additional files to further control the output.

In the template.php file add something similar to the lines that i commented, your function that the theme wizard will look similar with different names. It just prevents duplicate names from being output to the views theme engine.

This is pretty simple and there might be a better way but this worked for me.

Let me know what you think.

function phptemplate_views_view_list_VIEWNAME($view, $nodes, $type) {
  $fields = _views_get_fields();

  $taken = array();

 
  foreach ($view->field as $id => $field) {
    $field_name = $field['field'];
    if (isset($taken[$field_name])) {
      $field_name = $field['queryname'];
    }
    $taken[$field_name] = true;
    $field_names[$id] = $field_name;
  }

 
  $base_vars = array(
    'view' => $view,
    'view_type' => $type,
  );

  //$inalready = array ("");
  foreach ($nodes as $i => $node) {
    $vars = $base_vars;
    $vars['node'] = $node;
	
	// if (!(in_array($node->term_data_tid, $inalready))) {
		
		//$inalready[] = $node->term_data_tid;
	
		$vars['count'] = $i;
		$vars['stripe'] = $i % 2 ? 'even' : 'odd';
		foreach ($view->field as $id => $field) {
		  $name = $field_names[$id];
		
		  $vars[$name] = views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
		  if (isset($field['label'])) {
			$vars[$name . '_label'] = $field['label'];
		  }
		}
		$items[] = _phptemplate_callback('views-list-FAQ', $vars);
	  }
    }
  if ($items) {
    return theme('item_list', $items);
  }
}
leoklein’s picture

You'd think they're be an easier solution (after all these years). I've personally got no problem adding the above code but I wanted to demo this to people who might turn green if asked to do this.

I've had a look at a number of other Modules including Taxonomy Browser and Sitemap.

They kind of do what I want but, again, you'd figure it'd be easier to do something as basic as listing all Taxonomy Terms in a node.

Am I missing something?

gthing’s picture

You can accomplish this by using a view. After you have a view set up that lists each term - they will be listed as many times as there are nodes attached to them.

Add an argument to the view. Txonomy: Term Name and set the option to one of the "summary" options. You should get a list, each with a number of nodes contained in it.

Now the hard part is maintaining the list view where you can also include thumbnail fields. I can't figure out how to do that.

chris.rizyn’s picture

I was able to get this functionality by adding this to my template.php file.

function phptemplate_get_terms_of_vocabulary($v) {
    $vocabulary = taxonomy_get_vocabularies($v);
    if (count($vocabulary) != 1) {
        return false;
    }
	
    $terms = array();
    foreach ($vocabulary as $vocab) {}    //    strip the object out of the array

    $result = db_query("SELECT tid, name FROM {term_data} WHERE vid = %d", $vocab->vid);
    while ($r = db_fetch_array($result)) {
        array_push($terms, array('id' => $r['tid'], 'name' => $r['name']));
    }
    return $terms;
}

This function takes a singe variable: the name of the vocabulary whose terms you want. It returns false if the vocabulary is not found, else it returns an array of associative arrays giving each term id and term name.

Feedback is always appreciated!

chris.rizyn’s picture

All right, so the above only works if you have one vocabulary defined per content type. My apologies. Here's the corrected code:

function get_vocab($vocabulary_name) {
    if (!$vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE name = '%s'", $vocabulary_name))) {
        return false;
    }

    $terms = array();
    $result = db_query("SELECT tid, name FROM {term_data} WHERE vid = %d", $vid);
    while ($r = db_fetch_array($result)) {
        array_push($terms, array('id' => $r['tid'], 'name' => $r['name']));
    }
    return $terms;
}
tetramentis’s picture

I needed a list of terms of a specific vocabulary, linked to the listings of nodes assigned to those terms (just like admin's "list terms" menu).

In D6, this is easily done with Views:
- create a new view of type 'Term'
- leave style Unformatted, with no Grouping in options
- set row style to 'fields', don't change options
- in Fields group, add Taxonomy: Term, and set "Link this field to its taxonomy term page" checkbox
- in Filters group, specify proper Taxonomy: Vocabulary = 'your vocabulary'
- now add a Page display, and under "Page settings" add proper path to access this view

Here's sample view exported:

$view = new view;
$view->name = 'terms_list';
$view->description = 'A listing of all terms.';
$view->tag = 'default';
$view->view_php = '';
$view->base_table = 'term_data';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
  'name' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_taxonomy' => 1,
    'exclude' => 0,
    'id' => 'name',
    'table' => 'term_data',
    'field' => 'name',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'vid' => array(
    'operator' => 'in',
    'value' => array(
      '2' => '2', /* WARNING, CHANGE THIS TO YOUR PROPER vid */
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'vid',
    'table' => 'term_data',
    'field' => 'vid',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('title', 'terms list');
$handler->override_option('items_per_page', 0);
$handler->override_option('style_options', array(
  'grouping' => '',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'terms-list');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));
charlie-s’s picture

@tetramentis - perfect solution. Can't believe I messed with this so much and never thought to pick "term" as the Views type.

Perhaps it's time to branch out and learn what the other View types aside from Node are really for... sure it will save time in other areas too.

solona’s picture

Thank you gthing. I wouldn't have thought of this. Or at least not as quickly as from reading your suggestion.

--> I discovered that doing it this way makes it so that "Link this field to its taxonomy term" (or however it's worded) does not work. See solution below

solona’s picture

Here is the solution I used:

-Enable PHP as an Input Format (/admin/settings/filters) and check permissions to make sure only admin has access to it

-Create a custom block with PHP input format

-Enter SQL query:

$taxmenu = "SELECT tid, name FROM {term_data} WHERE vid = 3";
$result = db_query($taxmenu);
 while ($data = db_fetch_object($result)) {
 // $data is a node ... similar to a proper node object but not fully populated
 $output .= '<li><a href="'.$base_path.'/inspiration/'.urlencode($data->name).'">'.$data->name.'</a></li>';
 }
print $output;

*Note that vid = 3 happens to be the vocabulary ID that corresponds to the taxonomy I wanted to list the terms from. Yours may be different.

bwoods’s picture

Thanks teremka, I was looking for something just like what you submitted. I also added a join on my query to find values used by a particular content type, and a count of every time one of the terms is used:

SELECT td.tid, td.name, count(td.name) as count
FROM {term_data} as td, {term_node} as tn, {node} as n
WHERE tn.tid = td.tid and td.vid = [your vocabulary ID] and tn.nid = n.nid and n.type ='[your content type]'
GROUP BY td.name";

avpaderno’s picture

Priority: Normal » Minor

I am closing this issue, since it has been opened for a project version no longer supported. I apologize for bumping this issue.

avpaderno’s picture

Priority: Minor » Normal
Status: Active » Closed (outdated)