Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#8 | Image3.jpg | 158.64 KB | No Sssweat |
Comments
Comment #1
No Sssweat CreditAttribution: No Sssweat commentedComment #2
No Sssweat CreditAttribution: No Sssweat commentedComment #3
No Sssweat CreditAttribution: No Sssweat commentedComment #4
No Sssweat CreditAttribution: No Sssweat commentedComment #5
formatC'vt CreditAttribution: formatC'vt as a volunteer commentedHello, 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
Comment #6
No Sssweat CreditAttribution: No Sssweat commentedI tried the latest dev, and it did not solve the problem.
Comment #7
No Sssweat CreditAttribution: No Sssweat commentedComment #8
No Sssweat CreditAttribution: No Sssweat commented@formatC'vt to recreate this issue, create a new view of only comments.
(See image3)
Comment #9
formatC'vt CreditAttribution: formatC'vt as a volunteer commentedhmm, i think for this case you should use this module https://www.drupal.org/project/views_nodejs
Comment #10
No Sssweat CreditAttribution: No Sssweat commentedThanks 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?.
Comment #11
formatC'vt CreditAttribution: formatC'vt as a volunteer commentedyou can try this https://www.drupal.org/node/1404664#comment-7110546
Comment #12
No Sssweat CreditAttribution: No Sssweat commentedI 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.
Comment #13
formatC'vt CreditAttribution: formatC'vt as a volunteer commentedUnfortunately 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.
Comment #14
No Sssweat CreditAttribution: No Sssweat commentedI 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
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.
Note: remember to replace MyModuleName with the actual module name.
Comment #15
formatC'vt CreditAttribution: formatC'vt as a volunteer commentedi'm mean programmatically, call some function with view name and view row number/id/whatever and as result - html code for the row
Comment #16
No Sssweat CreditAttribution: No Sssweat commentedI 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.
Comment #17
No Sssweat CreditAttribution: No Sssweat commentedWell 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...?
Comment #18
formatC'vt CreditAttribution: formatC'vt as a volunteer commentedReplies 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.