Problem/Motivation

If you are looking at an API page on api.drupal.org with comments, such as:
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Datetime%...

Each comment is formatted with a clickable link for the comment subject/title, which takes you to a page like:
https://api.drupal.org/comment/65599#comment-65599

These pages have a bad display of the "node" that the comment is on, with the comment below.

The problem has to do with the way we're doing comments in the API module, which are on fake "nodes" because Drupal 7 and before didn't support commenting on anything but nodes. So if you go to a "node" page and it is an API fake node, you will get redirected to the actual API page for that documentation item. But this is not happening for Comment display pages.

Steps to reproduce

1. Visit https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Datetime%... or any other page with comments on api.drupal.org.

2. Click on a link for the subject/title of a comment.

3. Observe the top of the page, which is very confusing/useless, as it is trying to display the "node" the comment is about.

Proposed resolution

Several possibilities of how to fix this:

  • Wait until D8 version of API module. We will not be using nodes any more and our custom entities with comments will probably work better.
  • Possible work-around #1 for Drupal 7 version: don't output links to the comment pages when outputting comments on API "nodes".
  • Possible work-around #2 for D7: if someone tries to visit a comment display page and the comment is on an API node, redirect back to the docs page.
  • Possible work-around #3 for D7: Use the Comment Fragment module, which overrides these links. https://www.drupal.org/project/comment_fragment

Remaining tasks

a) Add the Comment Fragment module https://www.drupal.org/project/comment_fragment to api.drupal.org

b) Add a recommendation on the API module documentation for D7 to use this module.

User interface changes

Bad-looking comment pages will not be linked to or displayed.

API changes

None.

Data model changes

None.

Comments

jhodgdon created an issue. See original summary.

jhodgdon credited longwave.

jhodgdon’s picture

drumm’s picture

We use https://www.drupal.org/project/comment_fragment on some other Drupal.org sites to override this Drupal Core behavior.

jhodgdon’s picture

That looks like a good idea! But also the API module, which does weird things with nodes, should not allow that kind of comment page to be displayed... Or we could just suggest using that other module on API sites.

drumm’s picture

I believe what we see on the API site it just how Drupal Core works, at least for Drupal 7. Recommending the module makes sense, it has been straightforward to use in my experience. It was motivated by the comment links for project issues on Drupal.org, which had the same /comment/{cid} permalinks.

jhodgdon’s picture

Project: API » API.Drupal.org customizations
Version: 7.x-2.x-dev » 7.x-1.x-dev
Issue summary: View changes

OK then. It sounds like we should move this issue to apidrupalorg and add the Comment Fragment module to api.drupal.org there.

Meanwhile, I'll update the API module docs to recommend this module.

drumm’s picture

Assigned: Unassigned » drumm
Status: Active » Fixed

Comment Fragment is now enabled on API.Drupal.org

jhodgdon’s picture

Looks good! I verified on the page in the issue summary that those comment/# links are gone, and that if you have an old such link, it redirects to the API docs page. Problem is solved. Thanks!

Status: Fixed » Closed (fixed)

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