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.

CommentFileSizeAuthor
#2 mw.patch650 bytesmoshe weitzman

Comments

dave reid’s picture

Title: Document hook_node_view_alter() » Document missing hook_node_view_alter()
moshe weitzman’s picture

Title: Document missing hook_node_view_alter() » Remove hook_node_view_alter() in favor of #pre_render
Component: documentation » node system
Category: task » bug
Status: Active » Needs review
StatusFileSize
new650 bytes

Actually, 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.

dave reid’s picture

moshe, can you provide a mockup of how to replace hook_link_alter() with #pre_render? I'm not too familiar with that.

moshe weitzman’s picture

You 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

dave reid’s picture

This 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.

moshe weitzman’s picture

I 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.

moshe weitzman’s picture

Title: Remove hook_node_view_alter() in favor of #pre_render » Document missing hook_node_view_alter()
Status: Needs review » Active

I'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.

rfay’s picture

Title: Document missing hook_node_view_alter() » Document missing hook_node_view_alter()
Status: Active » Fixed

AFAIK, 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.

Status: Fixed » Closed (fixed)

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

fgm’s picture

Status: Closed (fixed) » Fixed

Reopening 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 reinstated hook_node_view_alter(). Other issues about hook_node_build_alter like #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.

rfay’s picture

I 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()?

fgm’s picture

I 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.

Status: Fixed » Closed (fixed)

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