Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi, thanks khalid for this module.
On my site's design I have a special block in wich I would like to print out the favorites widget. What changes would I need to make in order to make the favorites code avaiable in .tpl.php files, in a variable of its own... and to keep it from appearing in $links.
Regards,
JR
Comments
Comment #1
dotidentity CreditAttribution: dotidentity commentedAnybody?
Comment #2
Laurentvw CreditAttribution: Laurentvw commentedI'm also looking for this. Thanks in advance for anyone who could help us.
Comment #3
jp.stacey CreditAttribution: jp.stacey commentedThe $links variable is put together by PHPTemplate. It runs the following code to get it:
This states: if a node has links, then theme them in a 'links' context, with extra arguments in the array() at the end; if it doesn't have links, set $links to the empty string ''. The favorite_nodes module adds links to the node using the
hook_links
hook (in favorite_nodes.module).If you want to render just the favorite_nodes links, try putting the following in node.tpl.php:
Rendering everything except favorite links is a bit more tricky. Unfortunately, the
$node->links
array elements are just added to the end in order; there's no easy way of always spotting the favorite links except by checking each link's URL.A hack to do this might go as follows (stick in node.tpl.php as above; transfer to a block only when you're sure it works!):
All of this has the (minor) disadvantage that Drupal spends time creating $links for you, and then you create it a second time in two halves. There might be a way round that by using
node_load()
in a block, but it'd be messy.Does this help at all?
Comment #4
madaxe CreditAttribution: madaxe commentedAlthough this is stated for D5 version, I used jp.stacey's second section of code in the node.tpl.php in drupal 6.
It still works.