Show my links to visitors
dugh - July 12, 2008 - 22:54
| Project: | userlink |
| Version: | 5.x-1.2 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Jump to:
Description
It would be nice if the 'my links' block showed up for anonymous visitors too, like a blogroll or link roll.
Right now it only shows up when you yourself are logged in. Not much point in sharing links with yourself only.

#1
I changed the 'my links' block to use code like this to show the links to everyone:
else if (($delta == 1) &&
user_access('view all userlinks')) {
if (arg(0) == 'userlink' || arg(0) == 'blog') {
if (is_numeric(arg(1))) {
$uid = arg(1);
}
}
else if ((arg(0) == 'node') && is_numeric(arg(1))) {
$node = node_load(arg(1));
$uid = $node->uid;
}
if (!$uid) return null;
$block['content'] = userlink_list(db_query_range(db_rewrite_sql("SELECT n.nid, n.title, ul.url FROM {node} n INNER JOIN {userlink} ul ON n.vid = ul.vid WHERE n.type = 'userlink' AND n.uid = $uid ORDER BY n.title"), 0, 10));
if (!$block['content']) return null;
$block['content'] .= '<div class="more-link">'. l(t('more'),
'userlink/'. $uid, array('title' => t('See all the links.'))) .'</div>';
$block['subject'] = t('My Links');
return $block;
}
I changed the userlink_list function to return null if there were zero results of the sql query, so the block is hidden if there are no links to show.