Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I've installed this module on content types that I'm creating using panels. Is there any way I can insert the "add to favorites" link for appropriate nodes using a custom block as my node types don't display the content body (so I don't see the normal link)?
Thanks for any help.
Comments
Comment #1
asund CreditAttribution: asund commentedYou might want to take a look at the contemplate module (content template)
Anyway, if you'd like to do it manually it's pretty simple.
The add to favorite url is http://www.yourdrupalpath.com/favorite_nodes/add/[node-id]
Comment #2
Jboo CreditAttribution: Jboo commentedThanks paranaiv, that works great. I guess there could be a way to display the "add to favorites" link and then to show "remove from favorites" if the node has already been added using PHP?
Thanks again.
Comment #3
Liliplanet CreditAttribution: Liliplanet commentedHi,
Also would like this function please.
Code to insert in custom node-profile.tpl.php with 'add this user to favorites' and if selected, 'remove this user from favorites'.
Most appreciated.
Lilian
Comment #4
kbahey CreditAttribution: kbahey commentedWhy are you marking an issue critical when it is a support request. Nothing in the code is broken!
Also, why are you straying off topic?
For adding a user, use something to convert users to nodes, like node profile, content profile, or bio and then you can users to favorite nodes.
To answer the general question, you can add this anywhere in a node*.tpl.php to add an add/remove link.
It is best if we convert this to a themeable function. Patches welcome.
Comment #5
Liliplanet CreditAttribution: Liliplanet commentedThank you for your reply. I've tried the above in my .tpl and constantly receive an error syntax error, unexpected ','
Then copied the code from contemplate as follows:
<?php print $node->links['favorite_nodes_add']['attributes']['class'] ?><?php print $node->links['favorite_nodes_add']['href'] ?>
and nothing shows ..
Would most appreciate the correct code and thank you for your help.
Lilian
Comment #6
kbahey CreditAttribution: kbahey commentedTry this.
Comment #7
gabriel.ferreira CreditAttribution: gabriel.ferreira commentedI am having the exactly same problem, except that i'm using drupal 6.x and those codes didn't work here.
Comment #8
gabriel.ferreira CreditAttribution: gabriel.ferreira commentedComment #9
pisco23 CreditAttribution: pisco23 commentedsubscribing - did anyone get this to work?
Comment #10
kolashanpan CreditAttribution: kolashanpan commentedI need this too, but for Drupal 5.x
Please help
Thanks Knud
Comment #11
codevoice CreditAttribution: codevoice commentedSubscribing, is this something that can be made to work in a panel?
EDIT: This basic idea worked in a custom panel:
The problem in a panel is that the $node is not set when the panel code is processed (or rather, the variable isn't accessible at the time to the code), so using $node->nid doesn't work. The simple above example, however, does.