Hello,
First of all I would like to thank this lits for all the support I am receiving.
I am writing my first module. I would appreciate any help with my question.
I have created a content type called application. I am using two text fields and one filefield with this content type created using CCK. I am writing a custom module that does some operation on this node type when it is being created. Therefore I am using hook_nodeapi() in my custom module.
function loadapp_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL){ switch ($op) { case'submit': // Do operations here break; } }
I want to extract some information from this uploaded file and perform few other operations when the node is being created. I believe this be done with hook_nodeapi(). But how is the question. How can I access the filefield field when $op is 'submit'?
Sudheer ha scritto:
Hello,
First of all I would like to thank this lits for all the support I am receiving.
I am writing my first module. I would appreciate any help with my question.
[...] function loadapp_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL){ switch ($op) { case'submit': // Do operations here break; } }
I don't know the name of this field so my answer is: before "break" insert print_r($node); exit;
Ok, the node is not saved but you can see which is the exact name of all node's fields, CCK fields too. Are you sure for submit? Is not "insert" ? Or is better "prepare" ? I haven't here my Drupal Development book so sorry for the possible errors.
Hope help.
M.
Davide Michel 'ZioBudda' Morelli wrote:
Sudheer ha scritto:
Hello,
First of all I would like to thank this lits for all the support I am receiving.
I am writing my first module. I would appreciate any help with my question.
[...] function loadapp_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL){ switch ($op) { case'submit': // Do operations here break; } }
I don't know the name of this field so my answer is: before "break" insert print_r($node); exit;
Ok, the node is not saved but you can see which is the exact name of all node's fields, CCK fields too. Are you sure for submit? Is not "insert" ? Or is better "prepare" ? I haven't here my Drupal Development book so sorry for the possible errors.
Hope help.
M.
Thanks for the reply. Your approach to find the name of the variable is very good. Michelle helped with the same question on IRC. I use the devel.module and print the node object using the dsm() function.