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).

CommentFileSizeAuthor
views_comment_node_link.patch3.35 KBjoachim
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

deshilachado’s picture

Sounds 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"

joachim’s picture

Ah, 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.

WorldFallz’s picture

Status: Active » Needs review

patch attached, updating status.

lluser’s picture

"Error: handler for comments > node_link doesn't exist!"

joachim’s picture

Have you cleared your views cache?

deshilachado’s picture

Works for me as expected. Thank you!
Now I should invest some time to understand HOW it works...

lluser’s picture

>Have you cleared your views cache?

No, but now I tried it and it sitll doesn't work, same error :(

joachim’s picture

Could you check the file modules/comment/views_handler_field_comment_node_link.inc has been created by patching?

lluser’s picture

No, it was in sites\all\modules\views\modules, probably my mistake when patching...

merlinofchaos’s picture

Status: Needs review » Fixed

This is nice work. Thanks! Committed. Let's give 'er a spin.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

helenj’s picture

Status: Closed (fixed) » Active

I 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.

dawehner’s picture

I 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!

helenj’s picture

Thank 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.

dawehner’s picture

Status: Active » Fixed

so this is fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.