I'm currently converting a set of modules from 4.7.x to 5.1.

One of these modules is a custom Node type. I've made changes to a variety of locations that all seem to be working out (hook_form, hook_node_info, hook_view, etc...). I can display the Node creation form and once I check the database, the proper data exists in the proper location. However, I can't seem to load that data back into Drupal using hook_load. I'll paste my code below:

function q_sale_load($node) {
$sale_node = db_fetch_object(db_query('SELECT * FROM {q_sale} WHERE nid = %d', $node->nid));
return $sale_node;
}

This is essentially a straight adaptation from the code in node_example. The places in which the node does not show up are when I edit the node, and in the teaser and body.

I did make changes to hook_view, as per the upgrade instructions, maybe I've gone wrong there? I'll past that below as well:

function q_sale_view(&$node, $teaser = FALSE, $page = FALSE) {
$node = node_prepare($node, $teaser);

$node->content['body'] = array(
'#value' => theme('basic_sale_body', $node->body),
'#weight' => 1,);

return $node;
}

Does anything jump out for anyone? Is there some other place I need to look? I appreciate the help!

Comments

nevets’s picture

You do not mention them so I will first check that you have defined q_sale_insert($form) and q_sale_update($form) and that you have confirmed they are saving data to the table 'q_sale'.

You do not mention why you think q_sale_load() is not working, but it may have to do with you theme call. You have theme('basic_sale_body', $node->body) byt probably want theme('basic_sale_body', $node) since it is $node that will contain you additional data. If you table fields where 'field1' and 'field2' you would access them as $node->field1 and $node->field2.

antinomia_erik’s picture

I am currently having the same issue where hook_load is not loading. Did you ever resolve this?