I have created a new CCK content type with a range of fields. Now I would like to add a button (actually, several!) that appear when viewing the node. When you click one of the buttons, it causes the server to execute a PHP script.

The idea is that each node is a "lead" in a database for customers. After calling a customer, they may ask for us to send them an application form for several different products. We want to be able just to click on the appropriate button, and the PHP script on the server will grab the email address from the node, standard body text, and an attachment and email it to the customer....

So how can I add such a button to every node that causes the server to execute a PHP script?

Comments

nirbhasa’s picture

You'd need to create a small module that calls hook_form_alter to append a button

http://api.drupal.org/api/function/hook_form_alter

colinjones’s picture

nirbhasa

thanks for the info.... but way beyond me at this stage... don't suppose you could point me to a simple module that already uses such a hook? maybe I could manage butchering some existing module code to do what I want! Programmatically, what I'm trying to achieve is relatively simple... just need the leg-up on the glue around it on 1) how to make a piece of code into a piece of module code, 2) how to access/reference the CCK fields in the node from within the code so that I can set the destination email address.... etc.. :)

glennnz’s picture

hook_form_alter() won't work, colinjones wants to add the button to a NODE, not a form.

I've been trying to track this down for ages, any ideas anyone?

I can add the button, but I can't get it to fire another function.

colinjones, suggest you head to the local library and get a copy of Pro Drupal Development.

Glenn
THECA Group