Project:Favorite Nodes
Version:6.x-1.x-dev
Component:User interface
Category:support request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

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

#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

Version:5.x-1.2» 5.x-1.3
Priority:normal» critical

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

Priority:critical» normal
Status:active» closed (fixed)

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.

<?php
 
if ($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

Status:closed (fixed)» active

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

Status:active» fixed

Try this.

<?php
 
if ($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

Version:5.x-1.3» 6.x-1.x-dev

I am having the exactly same problem, except that i'm using drupal 6.x and those codes didn't work here.

#8

Status:fixed» active

#9

subscribing - did anyone get this to work?

#10

I need this too, but for Drupal 5.x
Please help

Thanks Knud

#11

Subscribing, is this something that can be made to work in a panel?

EDIT: This basic idea worked in a custom panel:

<?php
if ( !_favorite_nodes_check(arg(1)) ) {
print
l('add to favorites', 'favorite_nodes/add/'. arg(1));
} else {
print
l('remove from favorites', 'favorite_nodes/delete/'. arg(1));
}
?>

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.

nobody click here