hello merlin,

I have some issues with comments fields

first of all
Comment: Last Comment Author shows guest on every node... (btw. no guest is able to comment...)

I set a lot of fields to be sortable and added a Sort Criteria (Comment: Last Comment Date, descending)
if I take a look at this view I see the the sort-marker on the last column (which is false, because the default sort is another as by the last column)
but the greater issue is, that I'm unable to sort by one of the columns, instead of the default sort criteria...

maybe you can help me...

here comes the view, but attention: it uses the new "filter by comment count"-filter

but the problem occured before i did the patch, too.

  $view = new stdClass();
  $view->name = 'comment_list';
  $view->description = '';
  $view->access = array (
  0 => '2',
);
  $view->view_args_php = '';
  $view->page = TRUE;
  $view->page_title = 'Neueste Kommentare';
  $view->page_header = '';
  $view->page_header_format = '1';
  $view->page_footer = '';
  $view->page_footer_format = '1';
  $view->page_empty = '';
  $view->page_empty_format = '1';
  $view->page_type = 'table';
  $view->url = 'kommentare';
  $view->use_pager = TRUE;
  $view->nodes_per_page = '10';
  $view->block = TRUE;
  $view->block_title = 'Neuesten Kommmentare';
  $view->block_header = '';
  $view->block_header_format = '1';
  $view->block_footer = '';
  $view->block_footer_format = '1';
  $view->block_empty = '';
  $view->block_empty_format = '1';
  $view->block_type = 'list';
  $view->nodes_per_block = '4';
  $view->block_more = '0';
  $view->block_use_page_header = FALSE;
  $view->block_use_page_footer = FALSE;
  $view->block_use_page_empty = FALSE;
  $view->sort = array (
    array (
      'tablename' => 'node_comment_statistics',
      'field' => 'last_comment_timestamp',
      'sortorder' => 'DESC',
      'options' => '',
    ),
  );
  $view->argument = array (
  );
  $view->field = array (
    array (
      'tablename' => 'node',
      'field' => 'title',
      'label' => 'Titel',
      'handler' => 'views_handler_field_nodelink_with_mark',
      'sortable' => '1',
      'defaultsort' => 'ASC',
    ),
    array (
      'tablename' => 'node_comment_statistics',
      'field' => 'last_comment_timestamp',
      'label' => 'Letzter Kommentar',
      'handler' => 'views_handler_field_date_small',
      'sortable' => '1',
      'defaultsort' => 'DESC',
    ),
    array (
      'tablename' => 'node_comment_statistics',
      'field' => 'last_comment_name',
      'label' => 'von',
      'sortable' => '1',
      'defaultsort' => 'ASC',
    ),
    array (
      'tablename' => 'node_comment_statistics',
      'field' => 'comment_count',
      'label' => 'Anzahl',
      'handler' => 'views_handler_comments_with_new',
      'sortable' => '1',
      'defaultsort' => 'DESC',
    ),
  );
  $view->filter = array (
    array (
      'tablename' => 'node',
      'field' => 'status',
      'operator' => '=',
      'options' => '',
      'value' => '1',
    ),
    array (
      'tablename' => 'node_comment_statistics',
      'field' => 'comment_count',
      'operator' => '>',
      'options' => '',
      'value' => '0',
    ),
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(node_comment_statistics, node);
  $views[$view->name] = $view;

CommentFileSizeAuthor
#2 validate_defaultsort.patch.txt1.35 KBTobias Maier
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

merlinofchaos’s picture

Any 'sort criteria' you have specifically set will be put in, regardless of the table sort criteria.

What you need to do is remove your sorting criteria entirely, and set the proper field to 'default sort' => 'yes' in the fields. That should get you the result you seek.

Looks like the last comment author is failing because node_comment_statistics doesn't work the way I thought it works. Feh. Will have to find some time to fix.

Tobias Maier’s picture

Status: Active » Needs review
FileSize
1.35 KB

this patch is not the fix for the bug but enhances the process of validation...

I hope I did not understand Default Sort the false way... but you will see
added few t()'s.

merlinofchaos’s picture

Status: Needs review » Active

This is a good patch. Probably better would be, in the future, to turn the default sort thing into a radio button so that only one can be chosen, but I didn't think about that as a possibility until just now.

Patch committed tho there's still a bug here about the last comment author.

Tobias Maier’s picture

there is an spelling error in my patch...
"...et on Default Sort on one..."
the first "on"

thetrickyt’s picture

Version: 6.x-2.x-dev » 4.7.x-1.x-dev

I'm also experiencing the bug where the last comment author is appearing as 'anonymous' for all comment authors.

Any word on the fix for this part of the bug? I'm running the 4.7 version BTW.

merlinofchaos’s picture

Yea, don't use it.

Unfortunately, the information isn't actually in the node_comment_statistics table, unless the user was anonymous. It's my error thinking the info was there. So you really can't use this without patching comment.module

catch’s picture

Has anyone worked on a fix for the "anonymous" showing up in views? I'm also getting the same issue with both 4.7.0 and cvs versions.

merlinofchaos’s picture

Was I unclear in my previous comment?

catch’s picture

No you were clear, I was wondering if someone might've worked on a patch for comment.module as a workaround. Apologies if it looked like I was hassling,

merlinofchaos’s picture

Status: Active » Fixed

I spent some random time this evening and actually fixed this. Be surprised. =)

Anonymous’s picture

Status: Fixed » Closed (fixed)