Index: tagadelic_views.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/tagadelic_views/tagadelic_views.module,v
retrieving revision 1.1.2.5
diff -u -p -u -p -r1.1.2.5 tagadelic_views.module
--- tagadelic_views.module	23 Jun 2008 12:59:55 -0000	1.1.2.5
+++ tagadelic_views.module	11 Nov 2008 00:22:32 -0000
@@ -12,6 +12,12 @@ function tagadelic_views_views_style_plu
     'summary_theme' => 'tagadelic_display',
     'validate' => 'tagadelic_views_validate',
   );
+  $plugins['tagadelic_recurse'] = array(
+    'name' => t('Tagadelic Recurse'),
+    'theme' => 'tagadelic_display_recurse',
+    'summary_theme' => 'tagadelic_display_recurse',
+    'validate' => 'tagadelic_views_validate',
+  );
   return $plugins;
 }
 
@@ -26,7 +32,11 @@ function tagadelic_views_validate($type,
   form_error($form[$type .'-info'][$type .'_type'], t('The Tagadelic View requires one vocabulary field.'));
 }
 
-function theme_tagadelic_display(&$view, &$items, $type) {
+function theme_tagadelic_display_recurse(&$view, &$items, $type) {
+  return theme_tagadelic_display(&$view, &$items, $type, TRUE);
+}
+
+function theme_tagadelic_display(&$view, &$items, $type, $recurse = FALSE) {
   // get the views query and query parts (join and where) that we'll need
   $query = _tagadelic_build_query($view, $type);
   _tagadelic_views_parse_query($query, $join, $where);
@@ -46,6 +56,13 @@ function theme_tagadelic_display(&$view,
   if (strpos($join, ' LEFT JOIN {term_data}')) {
     $join = str_replace('LEFT JOIN {term_node} term_node ON node.nid = term_node.nid', '', $join);
     $join = str_replace('LEFT JOIN {term_data} term_data ON term_node.tid = term_data.tid', '', $join);
+    if ($recurse) {
+      // join with term_node again and use this new table for the first round of selection.
+      $join .= ' INNER JOIN {term_node} term_node_first ON term_node_first.nid = node.nid'; 
+      $where = str_replace('term_node.tid', 'term_node_first.tid', $where);
+      // exclude the terms initially passed in, since on a term view you are already looking at those.
+      $where .= ' AND (term_node_first.tid != term_node.tid)';
+    }
     $result = db_query_range('SELECT term_data.tid, COUNT(*) AS count, term_data.name, term_data.vid FROM {node} node INNER JOIN {term_node} term_node ON term_node.nid = node.nid INNER JOIN {term_data} term_data ON term_data.tid = term_node.tid '. $join .' WHERE (1)'. $where .' GROUP BY term_data.tid, term_data.name, term_data.vid ORDER BY count DESC', 0, $size);
   }
   else {
