My theme needed to place the Favore Node links in other locations. I've added a setting to turn off the addition of Favorite Node links and also added a theming function.

The code now looks like this:

/**
 * Implementation of hook_links().
 */
function favorite_nodes_link($type, $node = null, $teaser = false) {
  global $user;
  $links = array();
  if ($type == 'node' && !$teaser && variable_get(FAVORITE_NODES_SHOWLINK, 1)) {
    if (variable_get(FAVORITE_NODES_NODE_TYPE . $node->type, 0)) {
      if (user_access(FAVORITE_NODES_PERM_ADD)) {
        $links = theme('favorite_nodes_links',$node);
      }
    }
  }
  return $links;
}

/**
 * Allow theming of links().
 */
function theme_favorite_nodes_links($node) {
  if (!_favorite_nodes_check($node->nid)) {
    $links[] = array('title' => t('add to favorites'), 'href' => 'favorite_nodes/add/'. $node->nid);
  }
  else {
    if (user_access(FAVORITE_NODES_PERM_VIEW)) {
      $links[] = array('title' => t('in favorites'));
      $links[] = array('title' => t('remove from favorites'), 'href' => 'favorite_nodes/delete/'. $node->nid);
    }
  }

  return $links;
}

Comments

jpsalter’s picture

Status: Active » Needs review

Sorry. Forgot to set to "code needs review".

ahansen1’s picture

StatusFileSize
new2.78 KB

+1

Ported the patch to the 1.3 version. Really a very simple change to include.

kbahey’s picture

Status: Needs review » Needs work

Patch fails:

$ patch -p0 --dry-run < control_links-5.x-1.3.patch
(Stripping trailing CRs from patch.)
patching file favorite_nodes.module
Hunk #1 FAILED at 12.
Hunk #2 succeeded at 283 (offset 1 line).
Hunk #3 succeeded at 294 (offset 1 line).
Hunk #4 succeeded at 372 (offset 7 lines).
1 out of 4 hunks FAILED -- saving rejects to file favorite_nodes.module.rej

Please reroll.

jpsalter’s picture

Title: Add ability to turn off links, add ability to theme links » Add ability to turn off links, add ability to theme links and user page favorites
Version: 5.x-1.2 » 5.x-1.3
Status: Needs work » Needs review
StatusFileSize
new5.14 KB

Updated patch to v1.3 and added a theme function to hook_user $op=view.

Let me know if you want it rolled against .dev too.

kbahey’s picture

Version: 5.x-1.3 » 6.x-1.x-dev
Status: Needs review » Patch (to be ported)

Thanks, I committed this to 5.x-1.x-dev.

It needs to be ported to the 6.x-1.x-dev version as soon as possible.