Inserting add to favorites feature
Jboo - April 11, 2008 - 15:39
| Project: | Favorite Nodes |
| Version: | 6.x-1.x-dev |
| Component: | User interface |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
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.

#1
You 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]
#2
Thanks 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.
#3
Hi,
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
#4
Why 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.
<?phpif ($page) {
if (variable_get(FAVORITE_NODES_NODE_TYPE . $node->type, 0)) {
if (user_access(FAVORITE_NODES_PERM_ADD)) {
if (!_favorite_nodes_check($node->nid)) {
print l('add to favorites', 'favorite_nodes/add/'. $node->nid);
}
else {
if (user_access(FAVORITE_NODES_PERM_VIEW)) {
print l('remove from favorites'), 'favorite_nodes/delete/'. $node->nid);
}
}
}
}
}
?>
#5
Thank 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
#6
Try this.
<?phpif ($page) {
if (variable_get(FAVORITE_NODES_NODE_TYPE . $node->type, 0)) {
if (user_access(FAVORITE_NODES_PERM_ADD)) {
if (!_favorite_nodes_check($node->nid)) {
print l(t('add to favorites'), 'favorite_nodes/add/'. $node->nid);
}
else {
if (user_access(FAVORITE_NODES_PERM_VIEW)) {
print l(t('remove from favorites'), 'favorite_nodes/delete/'. $node->nid);
}
}
}
}
}
?>
#7
I am having the exactly same problem, except that i'm using drupal 6.x and those codes didn't work here.
#8
#9
subscribing - did anyone get this to work?
#10
I need this too, but for Drupal 5.x
Please help
Thanks Knud