Hi everyone,

I posted before (http://drupal.org/node/960922) about his problem, but it didn't describe the problem properly and need a bit more help solving the problem.

After I clear the cache the my node hooks for all of my modules do not get called, I think its something todo with the node_info declaration and/or the name of my hooks. Here is an example,

/*
* hook_node_info from gha_product.install
*/
function gha_product_node_info() {
    return array(
        'gha_product' => array(
            'name' => t('Product'),
            'module' => 'gha_product',
            'description' => t('Product'),
            'has_title' => TRUE,
            'title_label' => t('Product Name'),
            'has_body' => FALSE
        )
    );
}

/*
* hooks from gha_product.module
*/
function gha_product_insert($node) {
    // Save Product Info
    db_query("INSERT INTO {GHA_Product} (nid, title, cost_price, normal_price, published, description, stock_amount, image, supplier)
             VALUES (%d, '%s', %d, %d, %d, '%s', %d, '%s', %d)",
             $node->nid, $node->title, $node->cost_price, $node->normal_price, $node->published, $node->description, $node->stock_amount, $node->image, $node->supplier);
    // Save Product Service
    db_query("INSERT INTO {GHA_Product_Creation_Service} (id, product_id, creation_id, service_id) VALUES (NULL, %d, %d, %d)",
             $node->nid, 0, $node->service);
}
function gha_product_load($node) {
    
    drupal_set_message(t('gha_product_load'),'error');
    
    // Get Product Details and Service
    $additions = db_fetch_object(db_query('SELECT cost_price, normal_price, description, stock_amount, published, image, supplier FROM {GHA_Product} WHERE nid = %d', $node->nid));
    $service = db_fetch_object(db_query('SELECT service_id FROM {GHA_Product_Creation_Service} WHERE product_id = %d', $node->nid));
    $additions->service = $service->service_id;
    return $additions;
}
function gha_product_update($node) {
    // Update Product Info
    db_query("UPDATE {GHA_Product} SET title = '%s', cost_price = %d, normal_price = %d, description = '%s', stock_amount = %d, image = '%s', supplier = %d, published = %d WHERE nid = %d",
        $node->title, $node->cost_price, $node->normal_price, $node->description, $node->stock_amount, $node->image, $node->supplier, $node->status, $node->nid);
    // Update Product Service
    db_query("UPDATE {GHA_Product_Creation_Service} SET service_id = %d WHERE product_id = %d",
        $node->service, $node->nid);
}
function gha_product_delete(&$node) {
    // Delete Product Details and link to Service
    db_query('DELETE FROM {GHA_Product} WHERE nid = %d', $node->nid);
    db_query('DELETE FROM {GHA_Product_Creation_Service} WHERE product_id = %d', $node->nid);
}

I know its not being called by adding in a set_message into the node_load.

Any help would be greatly appreciated.

Paul

Comments

larowlan’s picture

Install files are only loaded as needed, try moving your hook_node_info into the module file.

Lee Rowlands

--author="larowlan <larowlan@395439.no-reply.drupal.org>"
paul.linney’s picture

Moving the hook_node_info into the .module file fixed the issue.

Thanks Lee

Paul Linney
Owner & Web Developer