Index: syndication.module
===================================================================
--- syndication.module	(revision 477)
+++ syndication.module	(working copy)
@@ -49,9 +49,15 @@
   if (module_exist('aggregator') && user_access('access news feeds')) {
     $output .= theme('box', t('External feeds'), syndication_opml());
   }
+  if (module_exist('category') && user_access('access content')) {
+    $categories .= syndication_categories();
+  }
   if (module_exist('taxonomy') && user_access('access content')) {
-    $output .= theme('box', t('Categories'), syndication_vocabularies());
+    $categories .= syndication_vocabularies();
   }
+  if (isset($categories)) {
+    $output .= theme('box', t('Categories'), $categories);
+  }
   
   // modules may add their own syndication boxes
   $result = array();
@@ -129,6 +135,20 @@
   return $output;
 }
 
+function syndication_categories() {
+   foreach (variable_get('syndication_categories', array()) as $cnid) {
+      $container = category_get_container($cnid);
+      $tree = category_get_tree($cnid);
+      // only show first 30 terms. wary of huge vocabs. not ideal. 
+      $tree = array_slice($tree, 0, 30);
+      $items = syndication_category_build_list_items($index = 0, $tree);
+      if ($items) {
+         $output .= theme('item_list', $items, $container->title);
+      }
+   }
+   return $output;
+}
+
 // helper function for syndication_taxonomy
 function syndication_taxonomy_build_list_items(&$index, $tree) {
   $items = array();
@@ -153,6 +173,30 @@
   return $items;
 }
 
+// helper function for syndication_category
+function syndication_category_build_list_items(&$index, $tree) {
+  $items = array();
+  $current_depth = $tree[$index]->depth;
+  while ($index < count($tree) && $tree[$index]->depth >= $current_depth) {
+    $term = $tree[$index];
+    $count = category_category_count_nodes($term->cid);
+    if ($count) {
+      $term_path = strtolower($term->title) . '/feed';
+      $term_link = l(t($term->title), $term_path, array('title' => t($term->description)));
+      if ($term->depth) {
+        $prefix = str_repeat('--', $term->depth). ' ';
+      }
+      $item = $prefix. $term_link . " ($count)";
+      $items[] = $item;
+      $index++;
+    }
+    else {
+      $index++;
+    }
+  }
+  return $items;
+}
+
 function syndication_users_validate($form_id, &$form) {
   $result = db_query("SELECT uid, name FROM {users} WHERE name LIKE '%s' AND uid > 0 ORDER BY access DESC", '%'. $form["name"]. '%');
   if (db_num_rows($result)) {
@@ -174,6 +218,18 @@
   foreach (taxonomy_get_vocabularies() as $vid => $vocab) {
     $options[$vid] = $vocab->name;
   }
+  if (module_exist('category')) {
+     foreach (category_get_containers() as $cnid => $container) {
+        $options_cat[$cnid] = $container->title;
+     }
+     $form['syndication_categories'] = array(
+        '#type' => 'checkboxes',
+        '#title' => t('Categories'),
+        '#options' => $options_cat,
+        '#default_value' => variable_get('syndication_categories', array()),
+        '#description' => 'Containers from the Category module',
+     );
+  }
   $description = t('Select the vocabularies which should appear in the <em>Categories</em> block on the %page', array('%page' => l(t('syndication page'), 'syndication')));
   $form['syndication_vocabularies'] = array('#type' => 'checkboxes', 
                                       '#title' => t('Vocabularies'), 
