1

I have this purchase module defined. And I have implemented the update hook something like this

<?php
  function purchase_update($node) {
    echo 'Updating';
    exit(0);
  }

  function purchase_help($path, $arg) {
    $output = ''; 
    switch ($path) {
      case "admin/help#purchase":
        $output = '<p>'.  t("Update help") .'</p>';
        break;
    }
    return $output;
  } 

However, whenever I edit a node of type purchase, it doesn't call my update function. Any suggestions what could go wrong?

1

Did the purchase-module create and implement the entire purchase node type or did you create that in the admin system?

If you created it in the admin-system you can't use those functions. They are for node type modules (a rarer and rarer kind of module use these days).

You probably want hook_nodeapi. It's a common misconception. http://api.drupal.org/api/drupal/developer%21hooks%21core.php/function/hook_nodeapi/6

function hook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'update':
      if($node->type == 'purchase') {
        echo 'Updating';
        exit(0);
      }
    break;
  }
}
  • You are a life saver. Although I feel drupal has been way unmanaged. If I need to find something, there is lot of hassle. I used to use drupal up to 6, then I felt it's not good for enterprise application. So I didn't go beyond. Now for small applications, I still use it, but version 6 and it's terrible to get support – rajan sthapit Nov 13 '12 at 21:17
  • 1
    Drupal 6 is a very useful CMS and framework but it is far from perfect. Drupal 7 improves a lot on it. Drupal 8 is coming up and it has even further improvements. People are making a tremendous effort to document and extend Drupal. It is a lot to take in and the learning curve is quite steep. I find Django easier to learn but I've done really nice things with Drupal. – Lars Wikman Nov 13 '12 at 21:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.