Better hook_menu() implementation
Scott Reynolds - October 8, 2009 - 21:26
| Project: | Smackdown |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | task |
| Priority: | normal |
| Assigned: | Scott Reynolds |
| Status: | closed |
Description
This here uses a menu loader to verify that its a smackdown node and then passes the access check to the user_access callback.
This makes it so people can menu_alter() this cleanly. And it makes life simpler...
| Attachment | Size |
|---|---|
| smackdown_menu.patch | 1.45 KB |

#1
doh ! wrong version of the patch. tab root isn't needed here. though its an interesting and important and undocumented part of hook_menu() the menu system will figure out the right root.
#2
I still spoke to soon. Instead we can use node_access('view', $node); And this totally works because the object handed to node_access() is a 'node'. Slick...
#3
... I failed to motivate this patch completly.
The reason to use a load function over an access function is really simple. If a user types in node/123/voting-results and 123 is not a smackdown node, what is the header you want sent. Access Denied or Page Not Found.
The load function will get you Page Not Found, which is what we want here.
#4
committed http://drupal.org/cvs?commit=278840
#5
Automatically closed -- issue fixed for 2 weeks with no activity.