Hi All,

I am trying to list all nodes from a particular vocabulary, grouped by the terms.

E.g.
a URL mysite.com/vocab1 will display the following:

Vocab1
- Term1
--- Node 1
--- Node 2
--- Node 3
- Term2
--- Node 2
--- Node 4
--- Node 5
- Term3
--- Node 1
--- Node 6
--- Node 7

I've been looking on the forums and found a number of threads about this, but none of them actually have a solution... just lots of links to external sites which are all dead.

The closest I got was using the views module, but even with that every time I add a new term to the vocab, I need to edit my view to include that term - and of course the view just sorts by the term, doesnt actually group by the term with sub headings on each term.

Before I sit down to write a module to do this, does anyone know of any contrib modules which already can do this?

cheers,

Comments

high1memo’s picture

well i went ahead and wrote a tiny little module to do what i want. You can see it in action at www.rogereaton.com/credits (credits is my vocabulary; feature films, television, documentaries etc. are the terminology for this vocabulary)

For those interested in the code to work on and enhance its below:


function msaextras_help($section) {
  switch ($section) {
    case 'admin/modules#description':
      return t('MSA set various paths like credits etc.');
  }
}

function msaextras_credits() {
	$content = '';

	$vid = 1;
	$terms = taxonomy_get_tree($vid);
	foreach($terms as $term) {
		$content .= "<h1 class='subheading'>$term->name</h1>";
		$nodes = taxonomy_select_nodes(array($term->tid), 'or', 'all', false);
		$content .= taxonomy_render_nodes($nodes);
	}
		
	print theme("page", $content);
}


function msaextras_menu() {

	$items = array();
	
	$items[] = array('path' => 'credits',
					'title' => t('credits'),
					'callback' => 'msaextras_credits',
					true,
					'type' => MENU_CALLBACK);
	
	return $items;
}