I noticed that when I post a new comment, the view does not update. Although, it works/updates when I use the reply button. So the issue is for comments that are not replies.

Side Note: when I use the drupal default comments, instead of using views, everything works fine.

CommentFileSizeAuthor
#8 Image3.jpg158.64 KBNo Sssweat
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

No Sssweat’s picture

Issue summary: View changes
No Sssweat’s picture

Issue summary: View changes
No Sssweat’s picture

Issue summary: View changes
No Sssweat’s picture

Issue summary: View changes
formatC'vt’s picture

Status: Active » Postponed (maintainer needs more info)

Hello, can you please try latest dev version?
I think this bug already fixed by this commit http://cgit.drupalcode.org/ajax_comments/commit/?id=652e065

No Sssweat’s picture

I tried the latest dev, and it did not solve the problem.

No Sssweat’s picture

Status: Postponed (maintainer needs more info) » Active
No Sssweat’s picture

FileSize
158.64 KB

@formatC'vt to recreate this issue, create a new view of only comments.
(See image3)

formatC'vt’s picture

hmm, i think for this case you should use this module https://www.drupal.org/project/views_nodejs

No Sssweat’s picture

Thanks for the suggestion, but...

The problem with that module is that it refreshes the entire view instead of just pulling the new content. Also, every time Node JS updates the view, it forces the page to auto scroll to the view which is annoying Stop Auto Scrolling?.

formatC'vt’s picture

No Sssweat’s picture

I was on vacation, just got back.

Thanks, I will give that a try soon, it will be handy for other stuff but...

Still the view's nodejs is not designed for comments. Since it refreshes the entire view instead of just pulling the new comment. So it won't work if someone had loaded more comments. They would be essentially be taken back to page 1 every time someone new comments. Also, if someone else comments on another node, it would cause all nodes comment view to refresh.

formatC'vt’s picture

Unfortunately i don't know how to render a single row of view. If you can help me with this information i think i can implement this feature.

No Sssweat’s picture

I know how.

I created a block view named comments222. I put a contextual filter of NID so it only shows the comments of the node you are viewing.

Copy the code below and paste this into admin/structure/views/import in the "Paste view code here" field

$view = new view();
$view->name = 'comments222';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'comment';
$view->human_name = 'comments222';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'comments222';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['style_options']['row_class_special'] = FALSE;
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['row_options']['default_field_elements'] = FALSE;
/* Relationship: Comment: Content */
$handler->display->display_options['relationships']['nid']['id'] = 'nid';
$handler->display->display_options['relationships']['nid']['table'] = 'comment';
$handler->display->display_options['relationships']['nid']['field'] = 'nid';
$handler->display->display_options['relationships']['nid']['required'] = TRUE;
/* Field: Global: View result counter */
$handler->display->display_options['fields']['counter']['id'] = 'counter';
$handler->display->display_options['fields']['counter']['table'] = 'views';
$handler->display->display_options['fields']['counter']['field'] = 'counter';
$handler->display->display_options['fields']['counter']['label'] = '';
$handler->display->display_options['fields']['counter']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['counter']['element_default_classes'] = FALSE;
$handler->display->display_options['fields']['counter']['counter_start'] = '1';
/* Field: Comment: Rendered Comment */
$handler->display->display_options['fields']['rendered_entity']['id'] = 'rendered_entity';
$handler->display->display_options['fields']['rendered_entity']['table'] = 'views_entity_comment';
$handler->display->display_options['fields']['rendered_entity']['field'] = 'rendered_entity';
$handler->display->display_options['fields']['rendered_entity']['label'] = '';
$handler->display->display_options['fields']['rendered_entity']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['rendered_entity']['element_default_classes'] = FALSE;
$handler->display->display_options['fields']['rendered_entity']['link_to_entity'] = 1;
$handler->display->display_options['fields']['rendered_entity']['display'] = 'view';
$handler->display->display_options['fields']['rendered_entity']['view_mode'] = 'full';
$handler->display->display_options['fields']['rendered_entity']['bypass_access'] = 0;
/* Sort criterion: Comment: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'comment';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Contextual filter: Content: Nid */
$handler->display->display_options['arguments']['nid']['id'] = 'nid';
$handler->display->display_options['arguments']['nid']['table'] = 'node';
$handler->display->display_options['arguments']['nid']['field'] = 'nid';
$handler->display->display_options['arguments']['nid']['relationship'] = 'nid';
$handler->display->display_options['arguments']['nid']['default_action'] = 'default';
$handler->display->display_options['arguments']['nid']['default_argument_type'] = 'node';
$handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25';
/* Filter criterion: Comment: Approved */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'comment';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status_node']['id'] = 'status_node';
$handler->display->display_options['filters']['status_node']['table'] = 'node';
$handler->display->display_options['filters']['status_node']['field'] = 'status';
$handler->display->display_options['filters']['status_node']['relationship'] = 'nid';
$handler->display->display_options['filters']['status_node']['value'] = 1;
$handler->display->display_options['filters']['status_node']['group'] = 1;
$handler->display->display_options['filters']['status_node']['expose']['operator'] = FALSE;

/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block');

As you can see, I added a result counter field to get the row number and a render comment field to render the comment.

Then all you have to do is use this code in your module.

function MyModuleName_preprocess_views_view_fields($vars){

  if ($vars['view']->name == "comments222" && 
      $vars['view']->current_display == "block" && 
      $vars['fields']['counter']->content != 1){
               $vars['fields']['rendered_entity']->content = null; 
               $vars['fields']['counter']->content = null; 
               }
}

Note: remember to replace MyModuleName with the actual module name.

formatC'vt’s picture

i'm mean programmatically, call some function with view name and view row number/id/whatever and as result - html code for the row

No Sssweat’s picture

I edited the code so it's easier on the eyes, the preprocess_views_view_fields($vars) function does that

If you look at the if statement, it has a view name ("comments222"), display type ("block") and the counter field is the row number ("1").

It's just a negative expression, if its not row 1, then don't print/render the row. Thus, only row 1 gets rendered.

so if you just want to print row 5 then you change this part of the code to $vars['fields']['counter']->content != 5

I'll look around if there is another way though, but this maybe the only way.

Important: You need to use my view set-up in order to get the code to work, so that's why I gave you the import code for the view.

No Sssweat’s picture

Well the question is, how come new comments don't work, but replies do? Is it a view row problem? But if the view renders the entity there shouldn't be any view rows...?

formatC'vt’s picture

Replies hardcoded to other comments, and we know after/before position for reply.
In Views result new comment maybe anywhere and we don't really know where. I think this is a reason for refresh the entire View.