By bslade on
The tutorial on writing modules in Drupal (see http://drupal.org/node/206754 ) covers blocks, not the more fundamental subject of node content. Does anybody have a tutorial about how to write node content related modules in Drupal?
Thanks
Ben Slade
PublicMailbox at benslade dot com
(add 030516 to the subj to bypass spam filters)
Comments
http://drupal.org/node/231019
http://drupal.org/node/231019
Re: http://drupal.org/node/231019 (node code example)
That example is interesting but doesn't add additional data fields to the node, which is not that general. But it does point the the more general example at:
http://api.drupal.org/api/file/developer/examples/node_example.module/6/...
which does provide the detail a generic node type that "has its own additional [data] fields [in addition to the (undefined) standard node data fields]"
The comments are still maddeningly obscure. For example, for the hook_load it says:
Here's my list of clarifications about the above hook_load paragraph:
Thanks
Ben Slade
There is even more to
There is even more to clarify, as I've found out the hard way:
- the hook_validate mentioned doesn't handle updates, the way its described
- the hook_update doesn't work, as $node is always the old node coming in
- I guess you'll need a hook_node_form_submit to handle the incoming values
As I'm new to writing modules, I only can say the the actual documentation on Drupal 6.x for node modules doesn't help to much. I've had to use a php debugger to dig into the details to make things work.
I still have an issue with validating updated data. The form always marks the field but shows the correct old data (which is actually stored in the database) instead of the newly miss-typed input, what needs to be corrected.
Actually I find it quite difficult to write a module for nodes with additional fields with the given documentation.
Regards
Werner
...
Hey, I agree that it would be great to have more example modules. But there are far too many possibilities to document everything in example modules. The best way to learn module development is to look at the code of other modules. The core modules are well documented and well coded. A number of contrib modules are equally great guides. Wanna' really learn Drupal? Study the source for user, node, forum, views, ubercart, etc.
There will always be room for improvement, but I think that the Drupal developer documentation has improved dramatically over the past 6 months. Kudos to all involved.
ubercart as a model for module development
I tried to learn from looking at ubercart as the first module to model my own after, and did indeed learn a lot. However it really was a pain in the arse because there is SOOOO many things going on, its difficult to see the whole picture. Tracing through the code across the various sub-modules is very time consuming if your new to the hook system. Overall, its very evident that the ubercart is well-planned and coded with customization and community expansion in mind.
What I needed (and probably still am looking for) is a simpler model to get up and running... something in between the utter simplicity of node_example.module and the uber-advanced multi-module concert that is ubercart.
James Wilson
Elementalidad