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.
Here's a patch on HEAD.
This adds a field that's basically the same node link that comment module puts on an ordinary node.
There's an option to show either the teaser version (shows nothing if logged out, comment count if logged in) or full version (shows an invitation to login or register if logged out, and a link to leave a comment if logged in).
Comment | File | Size | Author |
---|---|---|---|
views_comment_node_link.patch | 3.35 KB | joachim | |
Comments
Comment #1
deshilachado CreditAttribution: deshilachado commentedSounds interesting, I will try out this patch as soon as I have time, maybe this weekend.
Some time ago I tried to something similar: #365716: Please include a field with "add comment link"
Comment #2
joachim CreditAttribution: joachim commentedAh, I hadn't seen that other issue.
This patch works by:
- requesting additional fields from the node table
- faking up a $node object with properties from those fields.
- passing this to comment_link(), which is just comment module's hook_link
- passing the returned data to theme_links.
So in effect, you're getting an extract of the node links.
This means that comment module does all the work of figuring out if the user is logged in, whether the node allows comments, etc etc.
Comment #3
WorldFallz CreditAttribution: WorldFallz commentedpatch attached, updating status.
Comment #4
lluser CreditAttribution: lluser commented"Error: handler for comments > node_link doesn't exist!"
Comment #5
joachim CreditAttribution: joachim commentedHave you cleared your views cache?
Comment #6
deshilachado CreditAttribution: deshilachado commentedWorks for me as expected. Thank you!
Now I should invest some time to understand HOW it works...
Comment #7
lluser CreditAttribution: lluser commented>Have you cleared your views cache?
No, but now I tried it and it sitll doesn't work, same error :(
Comment #8
joachim CreditAttribution: joachim commentedCould you check the file modules/comment/views_handler_field_comment_node_link.inc has been created by patching?
Comment #9
lluser CreditAttribution: lluser commentedNo, it was in
sites\all\modules\views\modules
, probably my mistake when patching...Comment #10
merlinofchaos CreditAttribution: merlinofchaos commentedThis is nice work. Thanks! Committed. Let's give 'er a spin.
Comment #12
helenj CreditAttribution: helenj commentedI have applied this patch to Views, but am receiving the following error when I try to add the Comment: Node Link field to my view:
"An error occurred at http://www.example.com/admin/build/views/ajax/add-item/all-blogs/page_1/..."
I have run update.php, and ensured that the .inc file is in the correct location (..sites/all/modules/views/modules/comment).
Any advice much appreciated.
Comment #13
dawehnerI don't know whether you know it, but there is a stable views versions with this text applied.
To see the php error, disable your javasript in your browser and redo what you did to add the field. Then there should be a php error.
Could you please post this error here, thx!
Comment #14
helenj CreditAttribution: helenj commentedThank you. I wasn't able to see the php error, but I updated the module to the most recent version of Views and I am now able to use the Comments field.
Comment #15
dawehnerso this is fixed