Make a more-generic, more-modern subsystem for node/comment links, convert hook_node_links_alter(), hook_comment_links_alter()

Created on 5 March 2015, over 10 years ago
Updated 11 August 2025, 3 days ago

Problem/Motivation

A recent conversation in #drupal-contribute made me realize that hook_link() no longer exists as of D7, but hook_node_links_alter() and hook_comment_links_alter() still do.

It looks like this was partially (re)factored into the CommentLinkBuilder class for Drupal 8.0.x; but there are no EntityLinkBuilder nor NodeLinkBuilder classes.

I don't really know what we should do with this subsystem, but I'll throw out some random thoughts to consider...

  • Links displayed in this way might be useful if you want them to be really obvious to non-administrative users (e.g.: the "Add child page" links on book pages β€” especially useful in the Drupal.org handbook, because we want to make it easy / obvious for people to edit the handbook without losing context by going to node/add then later, when they're trying to put the page in the right place, find the book / page they were just looking at).
  • Now that Users, Taxonomy terms, etc. are all entities like Nodes and Comments, it might be useful to add similar-looking links to all of them.
  • In a way, these links kinda do something similar to Contextual links (although the links from these hooks are displayed in a different, more-visible place on the page). Maybe it's similar enough to become a subsystem of the Contextual links module?

Proposed resolution

To be determined.

Remaining tasks

To be determined.

User interface changes

To be determined.

API changes

To be determined.

✨ Feature request
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

other

Created by

πŸ‡¨πŸ‡¦Canada mparker17 UTC-4

Live updates comments and jobs are added and updated live.
  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for sharing your idea for improving Drupal.

    We are working to decide if this proposal meets the Criteria for evaluating proposed changes. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or there is no community support. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

  • πŸ‡¬πŸ‡§United Kingdom joachim

    Yes, this should be generalised to content entity types.

Production build 0.71.5 2024