Where can I find the best clear cut tutorial to writing a module? The purpose of the module I can already write in PHP and have code for, but how do I hook it into Drupal? The tutorial on this site was fuzzy to me.

Comments

jastraat’s picture

I find http://api.drupal.org/ really helpful.

------------------------------
http://fraggles.artsci.wustl.edu (Drupal user documentation and development blog)

kevinquillen’s picture

Yes I have. I don't find the Annotations example thorough enough, such as registering and setting the options inside of the Drupal admin, and how it interacts with everything else.

What I am trying to do is provide the user with a way to pick a content type this module will attach itself to.

For example, I want to be able to let a client create a node. This specific node type will only have a title, and use upload module to allow file attachments (image only). Then , it will present a list of already existing nodes in a multiselect, or checkbox array. When they select from these, this particular node will appear on those pages in a desigated block region, displaying a random image from it.

Header Image module is -close- to what I want to achieve, but I already added in my own hack so I could get the desired result. I have requested that it be added to the module, or I will have to build my own custom solution. The URL conditions options is great, but, I think it should present you with a checkbox array of nodes to select instead of requiring you to put in the system path or alias. It's just more intuitive for the layman then.

http://drupal.org/node/272468

===========
read my thoughts

jastraat’s picture

What you're looking to do should be pretty straightforward. Just look at this example: http://api.drupal.org/api/function/nodeapi_example_form_alter/6

Basically, the first half of the example _form_alter function alters the content type configuration form. (You could add a checkbox or radio button that allows the user to designate that type as the one to reference.) Then, the second half of the example function alters the actual node form on that specific node type, and you could use it to add a multiselect/checkbox field to nodes of a given type.

------------------------------
http://fraggles.artsci.wustl.edu (Drupal user documentation and development blog)

andybrace’s picture

i find the 'module builder' module saves a bit of time when setting up new modules - it allows you to select which hooks you want to use and then generates the .info file and a template .module file.

http://drupal.org/project/module_builder

joachim’s picture

... and I've just released a new version for D6 :)