Hi,

I would like to show the links for a node in a separate block.

I believed it was simple to do, but drupal make me become crazy about links management.

In my block, I enabled phpcode :

  $node = node_load(arg(1));
  drupal_set_message('<pre>'.print_r($node, true).'</pre>');

It successfully print my node, but there is no $node->links object.....

If I print the node object on the node.tpl.php file, the $node->links is correctly loaded.

Why node_load() don't load the links of a node ? How can I get them ?

Thanks

zmove

Comments

Afief’s picture

Subscribe

I have had this issue too and had to use an ugly hack to overcome it.

zmove’s picture

Hi,

I don't like to bump a post but after some hours of search, I still not able to find help neither on the documentation, neither on IRC channels, so the forum is my last option...

gcassie’s picture

This should get you a link array.

$tmp_node = node_load(arg(1));
$links = module_invoke_all('link', 'node', $tmp_node);

I believe the links are not in the node object itself because they are handled differently in preview, teasers, full view, etc.

EDIT: I tested that in Drupal 5. hook_link may work differently in 6.

zmove’s picture

Hi,

I confirm that it perfectly work for 6.x.

Thank you very much