Add ability to turn off links, add ability to theme links and user page favorites

jpsalter - April 17, 2008 - 22:53
Project:Favorite Nodes
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:jpsalter
Status:patch (to be ported)
Description

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:

<?php
/**
* 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;
}
?>

AttachmentSize
control_links_patch.patch2.6 KB

#1

jpsalter - April 17, 2008 - 22:55
Status:active» needs review

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

#2

ahansen1 - December 20, 2008 - 18:43

+1

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

AttachmentSize
control_links-5.x-1.3.patch 2.78 KB

#3

kbahey - December 25, 2008 - 15:48
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.

#4

jpsalter - January 3, 2009 - 22:45
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

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.

AttachmentSize
theme_user_page_and_links.patch 5.14 KB

#5

kbahey - January 4, 2009 - 02:41
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.

 
 

Drupal is a registered trademark of Dries Buytaert.