Hi,

Using a modified calendar view (see http://ur1.ca/do3a), grouping by a CCK Date field does not work. What puzzled me is that on my dev. environment it works. It is probably not a bug but a configuration error somewhere.

Does anybody have any idea of where to look ?

PS: I attached a screenshot of the view style config.

CommentFileSizeAuthor
view-group-date.png65.52 KBpbuyle

Comments

pbuyle’s picture

Category: support » bug

After some crude debugging, it appears that on my production site (where groupin is not working), in views_plugin_style::render_grouping($records, $grouping_field), $this->view->field[$grouping_field]->theme($row) returns an empty string. It appears to do so until $this->row_plugin->render($row) in first invoked later in views_plugin_style::render().

For quick reference, here is the full code for the two functions from views_plugin_style.inc

  /**
   * Render the display in this style.
   */
  function 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.
    $sets = $this->render_grouping($this->view->result, $this->options['grouping']);

    // Render each group separately and concatenate.  Plugins may override this
    // method if they wish some other way of handling grouping.
    $output = '';
    foreach ($sets as $title => $records) {
      if ($this->uses_row_plugin()) {
        $rows = array();
        foreach ($records as $label => $row) {
          $rows[] = $this->row_plugin->render($row); /*! Until the first pass here, $this->view->field[$this->options['grouping']]->theme($row) returns '' */
        }
      }
      else {
        $rows = $records;
      }

      $output .= theme($this->theme_functions(), $this->view, $this->options, $rows, $title);
    }
    return $output;
  }

  /**
   * Group records as needed for rendering.
   *
   * @param $records
   *   An array of records from the view to group.
   * @param $grouping_field
   *   The field id on which to group.  If empty, the result set will be given
   *   a single group with an empty string as a label.
   * @return
   *   The grouped record set.
   */
  function render_grouping($records, $grouping_field = '') {
    
    $sets = array();
    if ($grouping_field) {
      foreach ($records as $row) {
        $grouping = '';
        // Group on the rendered version of the field, not the raw.  That way,
        // we can control any special formatting of the grouping field through
        // the admin or theme layer or anywhere else we'd like.
        if (isset($this->view->field[$grouping_field])) {
          $grouping = $this->view->field[$grouping_field]->theme($row);
          if ($this->view->field[$grouping_field]->options['label']) {
            $grouping = $this->view->field[$grouping_field]->options['label'] . ': ' . $grouping;
          }
        }
        $sets[$grouping][] = $row;
      }
    }
    else {
      // Create a single group with an empty grouping field.
      $sets[''] = $records;
    }
    return $sets;
  }
pbuyle’s picture

Category: bug » support

Sorry, this is probably not a bug in views... But I'm still lost and don't know exactly where to look.

merlinofchaos’s picture

Status: Active » Fixed

Try the -dev version, which has had significant changes to the grouping. Note that I *just* made a commit, so try the -dev version after midnight GMT to get the most current version. I'm pretty sure this will fix your problems.

pbuyle’s picture

Status: Fixed » Active

Switiching to 6.x-2.x-dev doesn't solve the issue.

Worse, now all fields are displayed empty. The sourrounding markup is here, but actual rendering of field values is missing. I check the "Hide empty fields" in style parameters, all the fields and their labels are still displayed.

pbuyle’s picture

Ok, it's not a bug, reverting the theme to Garland fix both issues. All I have to do is to debug my theme...

pbuyle’s picture

Status: Active » Closed (won't fix)
pbuyle’s picture

Category: support » bug
Status: Closed (won't fix) » Active

The the culprit is views-view-field.tpl.php in my theme folder... but even when the file is the same as the original sites/all/modules/views/theme/views-view-field.tpl.php, the grouping doesn't work in views-6.x-2.6 and all field disapear with views-6.x-2.7.

Finaly, it may be a bug.

dyke it’s picture

i'm having the same problem grouping by content type in a block with HTML list, unformatted and grid. the table style is grouping fine.

i'm using the latest dev. i also tried switching my theme to garland which doesn't work.

dyke it’s picture

i updated to the latest dev and it didn't appear to be working at first, but then i changed "distinct" to "no" and it worked (on all views styles). yay! :)

pbuyle’s picture

In my case, the "distinct" value is already "no". And switching theme works, do does removing views-view-field.tpl.php from my theme.

tompte’s picture

I have the same problem.
Distinct or not...

dyke it’s picture

i was wrong, it isn't grouping properly whether distinct or not. i'm also having the same problem with grouping in all views.

Bilmar’s picture

subscribing

merlinofchaos’s picture

Status: Active » Postponed (maintainer needs more info)

Does this patch fix it? http://drupal.org/node/619884#comment-2250378 -- I suspect not. If that patch doesn't fix it, it may be a problem with date.module itself, because the grouping is ultimately handled by the style and I suspect you're using a date.module provided style.

Please test that patch and if that patch doesn't fix it, reroute this issue to date.module

pbuyle’s picture

Ok, I will try the patch asap. But if it doesn't fix the issue, I doubt the bug is in the date.module. As I said, removing the views-view-field.tpl.php file from the theme folder solve the issue. Even if it's an identical copy of the the original sites/all/modules/views/theme/views-view-field.tpl.php one. Also, when updating Views to 6.x-2.7, the issue is worse as all fields are rendered as the empty string. Again, having no views-view-field.tpl.php in the theme folder solve the issue in 6.x-2.7.

merlinofchaos’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

OH! If it's related to the presence of absence of that template, that's a core bug. =) I think it may be http://drupal.org/node/591804

kriskhaira’s picture

Note for others and myself — if you are using the Internationalization or Locale module, go to Date and time > Locale date settings and make sure the date format settings are consistent across different languages.