[development] Hook ordering
fsilva.pt at gmail.com
Fri Jan 5 16:04:09 UTC 2007
These are just ideas. Don't misunderstand me, I've already spot that
"hook_load and friends" vs "nodeapi" have just a difference: the first
is reliable to create a new node type from ground up; the second is
reliable to extend current node types adding new independent fields.
Now the question is that these are two ways that are being badly mixed
up. Do you want an example? nodeapi('delete revision')! If we are
working with the hook_load and friends and really do not need nodeapi,
there should be more hooks to allow the control (and development of a
complete node type) without recurring to *both* mechanisms.
The problem right know is quite simple: it is not possible to create a
fully node type without recurring to both node APIs. And (assuming
this) the questions are:
* why do have we to use both?
* if one will stand up, what will be?
* CCK does not solve the "basic" and "primitive" problem of creating a
fully node type, that is independent and that will not have fields
available to "share" with other node types (despite the fact that
almost everyone wants to say that CCK is the *only* future). CCK is
fantastic (with the generic fields) for the creation of user node
types and forms. Thats it.
* when developing a fully node type we have the need to know where,
when and how we can intercept some event (Drupal 5 has many new great
things to do this for forms)
Now, as I can see what you want is remove "nodeapi" stuff and convert
it for the hook_node_foo naming scheme. Nice, I'll help you with that:
* hook_load -> hook_node_load($when)
* hook_insert -> hook_node_insert($when)
* hook_nodeapi(op) -> hook_node_op($when)
* etc, etc, etc
Being that $when would have the values "before", "after" or empty
That would result in:
* hook_node_load('before') called for every available module
* hook_node_load() called only for the module that implements the
specific node type
* hook_node_load('after') called again for every available module
Ah, and if you want to change "hook" to something, you could try
"event", but why would we do that if we have only one understandable
On 1/5/07, Karoly Negyesi <karoly at negyesi.net> wrote:
> > We need more events, and with correct names for nodeapi:
> > Are you seeing what we can do here? Funny, we can add a "before
> > *event*" allowing us to do things before anything is done.
> > What do you think?
> You guys run on another track than I do.
> I am wrapping my head around renaming hook_nodeapi op foo to hook_node_foo and finding a better name for hook_load (which is not a hook). Functor came to my mind.
> I am vehemently against removing hook_load and friends -- it's ridiculous to remove a good, working concept just because it's confusing to some. When I explain Drupal coding I always explain that node system can be expanded in two, orthogonal directions, one being you can create your own node types and use hook_load and friends and the other direction being hook_nodeapi
More information about the development