I have a View which returns a list of nodes (custom content type) and I've added a Content: Add comment link field below each listing. Desired behaviour is for a user to see the list of nodes with a button to add a comment below each node, clicking the button links to a page with only that node, all its comments, but the link lands on the comment form (the link should be localhost/site_dir/node/[nid]#comment-form).
However, the view only shows the Add Comment Link for nodes which already have comments! I need the link to show on all nodes. I've tried a) checking that content permissions for comments are correct, b) making sure that comments are open for that content type, c) making sure the comment field isn't hidden for that content type. I don't know what else to try!
I would try rewriting the output on a Content: Link field, but I don't know how to make the links work from everywhere in the site, because the list of nodes appears on different pages from different paths.
Thanks in advance.
| Comment | File | Size | Author |
|---|---|---|---|
| #28 | comment-counter2.gif | 27.78 KB | mikeybusiness |
| #9 | 1490680.patch | 704 bytes | dawehner |
Comments
Comment #1
dawehnerIn general all what views is doing is to use the comment module functionality and display it, i'm wondering whether you have configured 'teaser' on the field?
So it would be cool if you have an export of your view.
Comment #2
jbucks commentedThanks dereine for your reply! I tried looking for I'm not sure what the proper protocol for attaching views exports is, I hope it's OK to post it to this comment like I've done, many apologies if not:
Comment #3
jbucks commentedI just tried with a fresh Drupal install (no changes to comment settings from the defaults). Steps to reproduce:
- Make a custom content type,
- Make a page view to return nodes of that type,
- Add a field Content: Add Comment Link
- Go to the page view.
If your nodes have no comments, then the link to add comments does not display.
Shouldn't the add comment link always display regardless of comments or not?
Comment #4
tlash commentedi see the same issue. did you find a solution?
Comment #5
samlarsen1 commentedI am also looking for a solution to this
Comment #6
martins.bertins commentedThis problem is not related with Views. I looked into this myself and found out that it is defined in the core (comment.module line 678) that the "Add new comment" link is shown when there is at least one comment or the comment form is in a separate page.
Comment #7
alex_shapka commentedMartin,
Apparently you wanted to say:
That's right, but then Views module should provide "Add new comment" field option, which would complicate things, since users would have to deal with two different "add comment" fields. So the best way would be if Views could make a check:
if a node has a comment then provide "Add comment" option
if a node does not have any comment yet, then provide "Add new comment" option
And I believe this is a bug rather than feature request, since Views should be able to provide everything that normal Drupal teaser does.
Comment #8
pixelsticks commentedI'm having the same issue and it's definitely slowing me down. Does anyone have a workaround they're using?
Comment #9
dawehnerYou know there is already an option for that "show teaser-style link", though it's hidden in the more section.
Let's move that out, because it's a really important setting on this handler.
Comment #10
dawehnerYou know there is already an option for that "show teaser-style link", though it's hidden in the more section.
Let's move that out, because it's a really important setting on this handler.
Comment #11
tim.plunkettI agree.
Comment #12
dawehnerAwesome thanks!
Comment #14
fraweg commentedHello,
have someone test the patch from "#9" ? Does it work?
Best regards
Frank
Comment #15
klokie commentedHi, the patch in #9 worked (I'm using views-7.x-3.5 which includes it), but the "Add comment link" field doesn't seem to allow rewriting. I'd like the link text to read "Comment" rather than "Add new comment", but that doesn't work. Is it fixed in 7.x-3.x-dev? Thanks
Comment #16
mollybt commentedThis was still an issue for me using views 7.x-3.5 . Here is a workaround in views:
Add a new field - Content: path
Exclude it from display
Add a new field - Global: Custom text
Then you write your link to add a comment:
<a href="[path]#comment-form">Add new comment</a>Comment #18
Vemma-1 commentedSo, how do we post the "Add New Comment" in all postings if there is no comments added? Would love to see the "Add New Comment" link appear regardless if there is no comment added. Wondering if I should delete the line mentioned above on the comment.module file. This same line still exist after a year or more from comment #6.
Comment #19
Vemma-1 commented#16
Posted by mollybt on January 18, 2013 at 6:17pm
This was still an issue for me using views 7.x-3.5 . Here is a workaround in views:
Add a new field - Content: path
Exclude it from display
Add a new field - Global: Custom text
Then you write your link to add a comment:
Add new comment
~~@~~@~~
After using from #16, I can see it in the Preview but not in the postings that are all on the front page as full content. Any ideas why this is not working if I can see it in the Previews? thank you mollybt!
Comment #20
schifazl commentedSubscribing to this!
Comment #21
samwilson commentedThanks for that idea @Vemma (#19 above), that works for me.
The Custom text should be:
<a href="[node]#comment-form">Add a comment</a>Comment #22
kopeboyWhat if I am displaying a Rendered Entity: Teaser and not fields?
Comment #23
MatthijsG commentedThis is in 2016 still an issue with Views 7.x-3.13 ...
The solution in #16 works for me, however i didn't add a custom text but rewrite it in the rewrite-section already (not sure what the exact English translation is).
Add the field node:path (or is it content:path? Again .. language isn't English..)
Check 'rewrite output of this field' under 'rewrite results'. Add something like
Your text
Check 'field as link' and leave the linkpath empty.
Slightly related, but offtopic ;-)
If you want to view the latest comment author, it shows with 0 comments the node author.
Add the field [last comment author] + [comment-count]. Hide the first one, rewrite the second one with [last comment author].
And .. hide [comment count] 'if empty', also when zero (2! checkboxes under rewrite)
Comment #24
rahul patidar commentedHi every one
I also faced this problem and I think that this is not related to view nor the patches are required. It's actually the content type setting, at least for my case. To solve this go to Admin > Structure > Content type here edit you content type. At the bottom on content type edit form you will see 'Comment settings' tab click it and uncheck the 'Show reply form on the same page as comments' checkbox. This did for me and hope you are looking for this.
Cheers!
Comment #26
Manoj Raj.R commented#16 Worked for me
Thanks @mollybt
Comment #27
buzzbee commentedWe are running Drupal 8.4.5 and are still having the same issue: the "add comment" link is not displayed when there are no comments AND the box next to "show replies on same page.." is un-ticked. I am sure I have missed something as this has been a problem for how many years? Could you please point me to it?
Comment #28
mikeybusiness commentedIt isn't views. #6 martins.bertins noted that it's the comment.module in core around line 679 in Drupal 7. If not empty is one of the conditions for showing the link.
Don't hack core by removing the comment count check.
"
!empty($node->commnet_count) &&"There may be a better place to put this but this is where google is sending people.
Comment #29
alternativo commentedI faced the same problem in D8.7.8
I have users with comment field, and a view of comments...did not shot add comment form if there was no comments done.
Solved making a view of users, showing comment field and filtered with contextual filter with user id.
Comment #30
paulocs@alternativo
can you write the steps to reproduce in drupal 8/9 in this issue https://www.drupal.org/project/drupal/issues/2965450?
Comment #31
damienmckennaPutting this back to "fixed", please continue further discussions in the core issue referenced above. Thank you.