I think that generated "Comment: View link" are not correct. It should be like

/?q=comment/17#comment-17

but it is like

/?q=node/6#comment-17

this wrong url is used also when displaying comment title as a link, and it does not
work with comments paging system.

Is this by design or this is a bug?

Comments

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new1001 bytes

Fix comment-link path.

dave reid’s picture

Status: Needs review » Reviewed & tested by the community

Yep, that's the correct link for comments as per comment_uri().

dawehner’s picture

Status: Reviewed & tested by the community » Fixed

Thanks.

Commited to the 7.x branch.

Status: Fixed » Closed (fixed)

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

troky’s picture

Status: Closed (fixed) » Active

Reopening this because of situation where CID is undefined or 0. For example: using comment view link in "Last Comment" relation when node doesn't have any comments.
Resulting link is: http://<site>/comment/#comment-

There are two possible solutions when CID is empty:
1. return empty string
2. return link to node itself like: http://<site>/node/{nid}

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

Which version do you use?

I'm pretty sure that's a problem of your configuration. So do you have "node" or "comment" as type of the view?

dawehner’s picture

In general i commited a fix currently for the field_comment.inc not field_comment_link.inc which might fix the issue, too.
So please text the current git version or wait a bit for the next dev image.

troky’s picture

Status: Postponed (maintainer needs more info) » Active

I am using latest dev.
Patched field_comment.inc won't fix this issue because comment link is created separately in both files and not related.

I don't see any problem in configuration because it is perfectly normal to have node without comments so "last comment cid" returns 0 or undefined and that case is not handled well in views_handler_field_comment_link.inc.

To be specific, I have modified Advanced Forum (topic list) view and in "Last post" column I want to have (beside timestamp and author) link to latest comment. If there are no comments at all http://<site>/comment/#comment- is returned so I can't even "hide when empty".

I made this modification in views_handler_field_comment_link.inc:function render_link:

before:

    $this->options['alter']['make_link'] = TRUE;
    $this->options['alter']['path'] = "comment/" . $cid;
    $this->options['alter']['html'] = TRUE;
    $this->options['alter']['fragment'] = "comment-" . $cid;

after:

    $this->options['alter']['make_link'] = TRUE;
    $this->options['alter']['html'] = TRUE;
    if (!empty($cid)) {
      $this->options['alter']['path'] = "comment/" . $cid;
      $this->options['alter']['fragment'] = "comment-" . $cid;
    } 
    else {
      $this->options['alter']['path'] = "node/" . $nid;
    }

... so returned link is always correct.

That 'else' could look like

    return '';

and one can use "hide when empty" option to handle data...

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new3.77 KB

This should be sure configurable and default to FALSE.

But there should be no link by default if $cid is empty because this always is wrong.

troky’s picture

Status: Needs review » Needs work

Nice idea but not working for me...

function render_link($data, $values) {
     if (!empty($this->options['link_to_comment']) && $data !== NULL && $data !== '') {
...

If $cid is empty, $data is empty and function returns NULL instead of link to node.

changed above code to:

function render_link($data, $values) {
     if (!empty($this->options['link_to_comment'])) {
...

and have link to node set to "node/" because $nid is empty as well.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new3.83 KB

It's somehow kind of cool that you tested and reviewed this patch, thanks!

Okay so what about this, removing the $data check, as the $cid will happen here anyway.

troky’s picture

Status: Needs review » Reviewed & tested by the community

this looks good.

dawehner’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for testing the patch. Commited to 7.x-3.x

Status: Fixed » Closed (fixed)

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