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;
}
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | theme_user_page_and_links.patch | 5.14 KB | jpsalter |
| #2 | control_links-5.x-1.3.patch | 2.78 KB | ahansen1 |
| control_links_patch.patch | 2.6 KB | jpsalter |
Comments
Comment #1
jpsalter commentedSorry. Forgot to set to "code needs review".
Comment #2
ahansen1 commented+1
Ported the patch to the 1.3 version. Really a very simple change to include.
Comment #3
kbahey commentedPatch fails:
Please reroll.
Comment #4
jpsalter commentedUpdated 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.
Comment #5
kbahey commentedThanks, 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.