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
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

asund - April 15, 2008 - 21:06

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

Jboo - April 18, 2008 - 13:21

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

Liliplanet - September 26, 2008 - 06:20
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

kbahey - September 26, 2008 - 14:07
Priority:critical» normal
Status:active» closed

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

Liliplanet - September 27, 2008 - 10:57
Status:closed» 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

kbahey - September 27, 2008 - 14:43
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

gabriel.ferreira - October 10, 2008 - 05:25
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

gabriel.ferreira - October 12, 2008 - 12:06
Status:fixed» active

#9

pisco23 - January 19, 2009 - 22:47

subscribing - did anyone get this to work?

#10

kolashanpan - March 22, 2009 - 15:36

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

Thanks Knud

 
 

Drupal is a registered trademark of Dries Buytaert.