Index: views_accordion_style_plugin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views_accordion/views_accordion_style_plugin.inc,v
retrieving revision 1.1.2.14
diff -u -p -r1.1.2.14 views_accordion_style_plugin.inc
--- views_accordion_style_plugin.inc	3 Nov 2009 18:52:03 -0000	1.1.2.14
+++ views_accordion_style_plugin.inc	7 Nov 2009 12:22:30 -0000
@@ -43,15 +43,17 @@ class views_accordion_style_plugin exten
     for ($i = 1; $i <= $maxitems; $i++){
       $rsopen_options[] = t('Row ') . $i;
     }
-
-    $form['use-grouping-header'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Use the group header as the Accordion header'),
-      '#default_value' => $this->options['use-grouping-header'],
-      '#description' => t('If checked, the Group\'s header will be used to open/close the accordion.'),
-      '#process' => array('views_process_dependency'),
-      '#dependency' => array('edit-style-options-grouping' => $options),
-    );
+    $uses_node_row_plugin = ($this->display->handler->get_option('row_plugin') == 'node');
+    if(!$uses_node_row_plugin) {
+      $form['use-grouping-header'] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Use the group header as the Accordion header'),
+        '#default_value' => $this->options['use-grouping-header'],
+        '#description' => t('If checked, the Group\'s header will be used to open/close the accordion.'),
+        '#process' => array('views_process_dependency'),
+        '#dependency' => array('edit-style-options-grouping' => $options),
+      );
+    }
     $form['start-open'] = array(
       '#type' => 'checkbox',
       '#title' => t('Start with a row opened'),
@@ -128,9 +130,48 @@ class views_accordion_style_plugin exten
    * Render the display in this style.
    */
   function render() {
-    $output = parent::render();
+    // this part is copied from (and should be exactly as) views_plugin_style render()
+    if ($this->uses_row_plugin() && empty($this->row_plugin)) {
+      vpr('views_plugin_style_default: Missing row plugin');
+      return;
+    }
+
+    // Group the rows according to the grouping field, if specified.
+    $uses_node_row_plugin = ($this->display->handler->get_option('row_plugin') == 'node');
+    if ($uses_node_row_plugin) {
+      $sets = array();
+      foreach ($this->view->result as $row) {
+        $node = node_load($row->nid);
+        $sets[check_plain($node->title)] = array($row);
+      }
+
+      // Render each group separately and concatenate.  Plugins may override this
+      // method if they wish some other way of handling grouping.
+      $output = '';
+      $this->view->row_index = 0;
 
-    // dpm($this->display->handler->get_option('fields')); // for dev-troubleshooting
+
+      foreach ($sets as $title => $records) {
+        if ($this->uses_row_plugin()) {
+          $rows = array();
+          foreach ($records as $label => $row) {
+            $rows[] = $this->row_plugin->render($row);
+            $this->view->row_index++;
+          }
+        }
+        else {
+          $rows = $records;
+        }
+        $output .= theme($this->theme_functions(), $this->view, $this->options, $rows, $title);
+      }
+      unset($this->view->row_index);
+    }
+    else {
+      $output = parent::render();
+    }
+
+    // Start of views_accordion custom render
+    // dpm($this->display->handler->get_option('fields'));
     // Preparing the js variables and adding the js to our display
     // we do it here so we dont have it run once every group
     drupal_add_js(drupal_get_path('module', 'views_accordion') .'/views-accordion.js');
@@ -147,16 +188,22 @@ class views_accordion_style_plugin exten
     $view_settings['usegroupheader'] = $view_settings['grouping'] ? $this->options['use-grouping-header'] : 0;
     $view_id = 'views-accordion-'. $this->view->name .'-'. $this->view->current_display;
 
-    if ($view_settings['usegroupheader'] == 1) {
+    $uses_node_row_plugin = ($this->display->handler->get_option('row_plugin') == 'node');
+    if ($uses_node_row_plugin) {
       $view_settings['header'] = 'h3.'. $view_id;
-    }
-    // Used to get the first field to be used as the accordion header
-    if ($view_settings['usegroupheader'] == 0) {
-      $i = 0;
-      foreach ($this->view->field as $id => $value) {
-        if (($i == 0) && ($value->options['exclude'] == 0)) {
-          $view_settings['header'] = 'views-field-'. str_replace('_' , '-' , $id);
-          $i++;
+      $view_settings['usegroupheader'] = 1;
+    } else {
+      if ($view_settings['usegroupheader'] == 1) {
+        $view_settings['header'] = 'h3.'. $view_id;
+      }
+      // Used to get the first field to be used as the accordion header
+      if ($view_settings['usegroupheader'] == 0) {
+        $i = 0;
+        foreach ($this->view->field as $id => $value) {
+          if (($i == 0) && ($value->options['exclude'] == 0)) {
+            $view_settings['header'] = 'views-field-'. str_replace('_' , '-' , $id);
+            $i++;
+          }
         }
       }
     }
