I have a module that defines 3 node types...a, b, and c for simplicity.

For all of these nodes, mymodule_a_load does not exist according to module_hook.

I have added this code to node.module:

    print node_get_base($node) . '_' . $hook;
    if(function_exists(node_get_base($node) . '_' . $hook)) { print "YES for $hook"; } else { print "NO for $hook"; }

the output is: mymodule_a_load NO for load mymodule_a_view YES for view mymodule_a_view YES for view

What this is telling me is that drupal doesn't think that mymodule_a_load exists...trust me, it does...I have the same problem for all 3 node types!?!?! Also, why is it running mymodule_a_view twice???

Any hints would be greatly appreciated!

Comments

dblado’s picture

Title: pulling my hair out on module_hook returning false for my function mymodule_nodetype_load » workaround: added mymodule_a_load($node) as first line of mymodule_a_view

I was able to workaround my issue by adding mymodule_a_load($node) in my view hook...not the cleanest, and probably not 'drupal' safe...but it seems to be working, so I'm gonna go with it :)

If anyone knows why my load hooks aren't working I'd love to hear!

chx’s picture

It's extremely hard to understand what are you talking of. What the heck module_hook is supposed to be? There is no such thing.

dblado’s picture

Hi Chx,

Let me try to explain better...

I have a module w/ 3 node types...none of the 3 node types receive a call to function mymodule_nodetype_load($node)

following the stack trace for node_load we get:

node.module - node_load()

    // Call the node specific callback (if any) and piggy-back the
    // results to the node or overwrite some values.
    if ($extra = node_invoke($node, 'load')) {
      foreach ($extra as $key => $value) {
        $node->$key = $value;
      }
    }

node.module - node_invoke()

function node_invoke(&$node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
  if (node_hook($node, $hook)) {
    $function = node_get_base($node) ."_$hook";
    return ($function($node, $a2, $a3, $a4));
  }
}

node.module - node_hook() - comments were my debugging additions

function node_hook(&$node, $hook) {
//    print node_get_base($node) . '_' . $hook;
//    if(function_exists(node_get_base($node) . '_' . $hook)) { print "YES for $hook"; } else { print "NO for $hook"; }
  return module_hook(node_get_base($node), $hook);
}

module.inc - module_hook() - for me this is returning false on mymodule_nodetype_load() calls


function module_hook($module, $hook) {
  return function_exists($module .'_'. $hook);
}
killes@www.drop.org’s picture

Version: 4.7.0-beta5 » 4.7.0
Status: Active » Closed (won't fix)

Use nodeapi