By mixersoft on
I can use hook_links() to add a link to my node, but I don't know how to get that link displayed in the body except by manually adding it to the node_body in hook_view(), i.e.:
$node->body .= l($link[<link name>]['href'])
However, this doesn't handle $link properly when the format of the link is a "non-link" (i.e. w/o an href). What is the proper method for doing this?
Comments
Here's what I do
The link shows up at the bottom of the node.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
all right, I'm a newbie but
hat's the output from the hook_links() function.
Here's a snippet from product.module:
But what do you mean that it automatically shows up at the bottom of the node?
Actually, I should clarify that the place I want it to show up is in a view of the node, which is why I am messing with $node->body and $output from above. If I'm putting the link in a view, should it also automatically show up?
Well...
Since I don't use hook_view, the standard node presentation places the links at the bottom of the display of the node. But I would think that any view presentation would include them. Take a look at how the node module does it and compare it to yours.
Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database
NancyDru
Normally the links are part of node.tpl.php
The links are typically printed in node.tpl.php something like this
While often after the content you can also place them before the content.
I'll take a look here, it will be useful for other stuff. But
The output, $links = hook_links(), is an array. is this the same $links that you can simply print in node.tpl.php?
Figured it out
You have to theme the output from hook_links() to get it to display it properly:
So in hook_view() for the module in question, I just added:
Thanks for the tip on node.tpl.php, it got me thinking in the right direction.