Thanks for your time in advance.
I am new to drupal 4.7 ,but from a coders view, I am very excited about this product.
I am still not able to see the forest for the trees however and hence this post.
I am writing a custom module that implements a new node type for a client.
In this project, I am "the data guy" vs "the presentation guy". my role is to store, retrieve
and manipulate data and keep the underlying db normalized and sane.
From a data perspective, I need to keep my modules custom tables in sync with the node and users table whenever a node is added/edited/updated/deleted and same for the users use cases.
On the SQL side, it is very simple, but on the DRUPAL side, I need to decide on a best practices strategy for implementing callbacks that handle these base db tasks.
For example, on the IBM tutorial site, their hook_menu implementation included many callbacks to node_page. However, at my jobsite, a previous developer developed a module that invoked only custom callbacks.
What is your advice? custom callbacks or the default node_x functions for manipulating a custom node type?
Here is my knowledge base to date:
I have taken a first pass in studying:
- ibm's tutorial
- new module development guide on this site
- forms api
- a forum post that recommended using the forms api for custom administration functionality and the hook_ system for managing node updates/edits/deletes.
My todo-list for studying includes:
- theming techiques besides those in forms api so I can give the presentation developer the stuff he needs in the way he needs it
- search strategies so I can help in searching/tagging my new node type (ibm had some on this that I need to study in depth)
- node_x functions (I plan to do this in the morning unless the replies to this post tell me to go down and easier path
Thanks for any advice,
t.
p.s. We have decided against CCK/Views because this will force us to become more acquainted with the core api--which will help us as we take on new custom projects.
Comments
Answer: definitely local callbacks
I looked at the hook_menu callback for all the modules installed on our development site.
callbacks to the "core" node or other non-local functions only occur in the following modules with percentages..:
The following modules use local callbacks exclusivelly:
So, it seems the prudent choice in response to my original post is to heavily favor local callbacks over calls to other modules.
In time, I hope to understand why the IBM tutorial uses calls to the node_x functions over local callbacks.
cheers.
t.
Answered my question too
Thanks for your good question and excellent answer. It saved me a bit of time today.
your welcome.
For what it is worth,
During my research and ongoing development in getting a custom search working for a module I am developing (http://drupal.org/node/124963) I learned that a module can invoke a hook on itself--
Not that I know how to implement it, but things like that can really inform architectural decisions.
best of luck.
t.