A new hook_node_view_alter() was introduced in #339929: Move node links into $node->content and it is currently not documented in node.api.php.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | mw.patch | 650 bytes | moshe weitzman |
A new hook_node_view_alter() was introduced in #339929: Move node links into $node->content and it is currently not documented in node.api.php.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | mw.patch | 650 bytes | moshe weitzman |
Comments
Comment #1
dave reidThis issue is now linked from #217912: Document undocumented hooks (currently 1 remaining on list).
Comment #2
moshe weitzman commentedActually, I now realize that this hook is not needed. Modules can add a #pre_render during nodeapi('view') to any element they wish. I'll also note hat #post_render is available if moduls want to alter 'finished html' instead of an array.
Comment #3
dave reidmoshe, can you provide a mockup of how to replace hook_link_alter() with #pre_render? I'm not too familiar with that.
Comment #4
moshe weitzman commentedYou add [#pre_render][] = 'my_function' to the link(s) you want to change. Then your function gets called with $elements as an arg. Sorry, I can't provide full code here. What you ask for is drupal_render() documentation which is out of scope. The relevant code is in drupal_render(). Search for #pre_render.
Other docs:
- Pro Drupal Dev (v5): http://books.google.com/books?id=aWYOGXQShegC&pg=PA172&lpg=PA172&dq=%23p...
- The issue where we added #pre_render: http://drupal.org/node/147662
Comment #5
dave reidThis implementation seems very hackish, but I'm experimenting with it. We will need to be able to show somehow (including example code) to module updaters how to replace hook_link_alter on the 6.x -> 7.x doc page. I just happen to be one of the maintainers that implements a hook_link_alter() in one of my contrib modules, so that's why I'm particularly interested in how this is progressing.
Comment #6
moshe weitzman commentedI would prefer to say 'unfamiliar', instead of hackish. The drupal_render() API is standard for nodes, users, and forms, so it behooves developers to learn it. On the other hand, a new hook like nodeapi(alter) is specific to node view. So reducing special cases is usually a desireable change.
Comment #7
moshe weitzman commentedI'm going to backtrack and say that this hook is still useful. It would be annoying to catch every node rendering and add yourself as a pre_render.
Comment #9
rfayAFAIK, hook_node_view_alter() was removed in #367214: hook_node_alter almost disappeared ?, so this issue is dead. I find no trace of it remaining in the code.
Comment #11
fgmReopening as fixed just so search engine can find it and anyone looking for info about
hook_node_build_alter()can find out this has been replaced by the reinstatedhook_node_view_alter(). Other issues abouthook_node_build_alterlike #499212: Inconsistency in entity view/build/build_alter function invocations and hook names and #409750: Overhaul and extend node build modes do not make this visible.Comment #12
rfayI don't see appropriate coverage of this in http://drupal.org/update/modules/6/7.
Shouldn't there be an item: hook_node_build_alter() replaced by hook_node_view_alter()?
Comment #13
fgmI don't think there should: hook_node_build_alter() appeared during the D7 dev cycle, apparently from renaming hook_node_view_alter(), then was canceled sometime in the autumn and renamed back to hook_node_view_alter().
I couldn't find an issue, but patches including hook_node_build_alter() ceased to include it at some point and hook_node_view_alter() reappeared. So since it only affects those few who tried to do ports on the various D7 UNSTABLE and not the general D6->D7 porters, it's probably not worth documenting. I just re-opened this issue because it took me some time to figure what had happend because I had code on UNSTABLE-8 using it.