Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I have implemented a hook_nodeapi in a Drupal 6 site. When looking into the node, I found out the node->taxonomy is not loaded. This means taxonomy_nodeapi is not invoked before my hook even though the weigh of my module is greater than taxonomy.

Edit Adding code:

hook_nodeapi(&$node, $op, $arg = 0) {
if ($node->type == 'articles' && $op == 'load') {
  dpm($node)
 }

I think this may be default behaviors. Invoking taxonomy_nodeapi() directly works for me but I am still wondering as to why this is the case.

share|improve this question
    
what $op in your nodeapi call are you using? –  Jimajamma Feb 26 '13 at 22:41
    
can you add your implementation in the question section? –  Aboodred1 Feb 26 '13 at 22:52
add comment

2 Answers

up vote 1 down vote accepted

I think I am explaining this right, but the issue here is that hook_nodeapi() called with op = load returns a keyed array that is later on merged into the node object. It doesn't do this in sequence and progressively build up as each module's hook is executed, eg, it doesn't modify the node object itself. Thus it does not allow other modules to look at any other extra load information from other modules until later on.

For example, taxonomy_nodeapi() called with op = load loads up the taxonomy term info and returns it as $output['taxonomy']. So, it is never available to any other modules until the node_load() where it is then turned into $node->taxonomy based upon that key. Here, all other modules that add to $node in the same way also add in their extra stuff.

So yes, this is probably best described as default behavior.

share|improve this answer
    
This is what I figured after looking at taxonomy_nodeapi. It does this ' $output['taxonomy'] = taxonomy_node_get_terms($node); return $output; `. It does not modify the node object. –  awm Feb 27 '13 at 16:07
add comment

Your module might be loaded after the taxonomy module. If you want to check for this, you can update the weight information in the system table. If your module has a weight of 5 and taxonomy has a weight of 0, your module will be loaded after the taxonomy module

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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