0

With Views, I want to output a list that links to each comment of the current node. But instead of linking to

/comment/42#comment-42

I want to link to

/node/23#comment-42

I tried these fields, but they all link to the URL in the /comment/ space:

  • Comment: Title (Formatter: Plain text)

    /comment/42
    
  • Comment: Title (Formatter: Comment Permalink)

    /comment/42#comment-42
    
  • Comment: Link to Comment

    /comment/42
    

Is there a way to output anchors in the /node/ space? The solution doesn’t need to support comment pagination (a node will never reach the limit).

1

An ugly workaround (which will not work for paginated comments):

  1. Add the field "Content: Link to Content"

    1. Use the relationship "Content" (should be default when creating a comments view)
    2. Enable "Exclude from display"
    3. Enable "Output the URL as text"
  2. Add the field "Comment: Comment ID"

    1. Set "Formatter" to "Unformatted"
    2. Enable "Exclude from display"
  3. Add the field "Comment: Title"

    1. Set "Formatter" to "Plain text"
    2. Disable "Link to the Comment"
    3. Enable "Output this field as a custom link" (under "Rewrite results")
    4. Link path: {{ view_node }}#comment-{{ cid }}
      (field names might differ, use what’s listed under "Replacement patterns")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.