hook_link_alter is called twice per node; Once for the links section (links like 'read more', normally below the node body), and once for the taxonomy links section (links to terms, normally above the node body). If hook_link_alter is used to add a link, this link to the $links array, this link shows up on both sections. This leads to confusion: http://drupal.org/node/217017. Instead, it is more logical to use hook_link to add a link to the links section.
The api documentation describes hook_link_alter as follows:
Perform alterations before links on a node are rendered. One popular use of this hook is to add/delete links from other modules.
This would be a better description:
Perform alterations before links on a node are rendered. One popular use of this hook is to modify/remove links from other modules.
The description would probably benefit from the following addition:
If you want to add a link to the links section of a node, use hook_link instead.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | jamesan_271515.patch | 795 bytes | JamesAn |
| #4 | jamesan_271515-D6.patch | 840 bytes | JamesAn |
| #4 | jamesan_271515-D5.patch | 726 bytes | JamesAn |
Comments
Comment #1
heather commentedChanged the component to reflect the new component categorization. See http://drupal.org/node/301443
Comment #2
add1sun commentedMoving to queue for API docs.
Comment #3
karschsp commentedtagging for novice queue.
Comment #4
JamesAn commentedThe description in the patch reads:
Perform alterations before links on a node are rendered. One popular use of this hook is to modify/remove links from other modules. If you want to add a link to the links section of a node, use hook_link instead.Comment #5
catch#451272: Rename or remove or do *something* with hook_link() will probably remove hook_link() from Drupal 7, but let's get this in anyway for now. By the way, if you apply for a CVS account, you'll be able commit the Drupal 5 and Drupal 6 core.php patches yourself
Comment #6
dries commentedCommitted to CVS HEAD. Lowering version.
Comment #7
gábor hojtsyCommitted to the D6 contrib docs core.php file. Moving to D5. Sorry, don't have time to commit to there now, but due to how the components work, this was in the core isssue queue and obscured my view of outstanding issues :)
Comment #8
drummCommited to 5.x. Anyone with a contrib cvs account can do this.