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;
}
?>| Attachment | Size |
|---|---|
| control_links_patch.patch | 2.6 KB |

#1
Sorry. Forgot to set to "code needs review".
#2
+1
Ported the patch to the 1.3 version. Really a very simple change to include.
#3
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
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.
#5
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.