Show links on non-node pages
luke76 - January 28, 2008 - 02:25
| Project: | Service links |
| Version: | 5.x-1.1 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
hi, my service links are showing as i have selected in my full page node views, but i cannot seem to display the block?
using seo position theme, though have tried in garland with no luck either.
thanks for any ideas...

#1
Where have you positioned the block in the Blocks admin settings?
Do you have a link we can see?
#2
cannot reproduce here. can you provide more information about your setup/configuration ?
#3
Hi
I decide the block was overkill anyway in the end and have decided to go without, just using links on nodes. The set up was drupal 5.7, on MAMP using Firefox - positioning the block at the top of the left sidebar.
Thanks for your response anyway, sorry can't be more specific, had to be honest forgotten the issue.
#4
I was having the same problem. It turns out my issue was that the service links are designed only to show on node pages, not on views, panels, the home page, or anywhere that's not a node. I would like my users to be able to bookmark and share any page on the site, so I would like to propose a second non-node specific block for these other locations.
I tried to alter the block that was there, adding a setting for where admins wanted that block to be, but It looks like this approach won't work because the node is needed for building the links. Can we create another function that can build service links using the current url rather than relying on a node?
Jen
#5
#6
jenlampton,
I also needed the ability to bookmark the current page regardless of whether it's a node or not, so I just threw together a working solution. You will need to modify two functions in the service_links.module file:
find function service_links_block()
replace this:
<?php
if (user_access('use service links') && arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(arg(1));
$links_show = _service_links_show($node->type, $node->nid);
if ($links_show) {
$block['subject'] = t('Bookmark/Share this');
$block['content'] = theme('service_links_block_format', service_links_render($node));
}
return $block;
}
?>
with this:
<?php
if(user_access('use service links'))
{
$block['subject'] = t('Bookmark/Share this');
if(arg(0) == 'node' && is_numeric(arg(1)))
{
$node = node_load(intval(arg(1)));
if(_service_links_show($node->type, $node->nid))
$block['content'] = theme('service_links_block_format', service_links_render($node));
}
else
{
$protocol = strtolower(substr($_SERVER['SERVER_PROTOCOL'], 0, strpos($_SERVER['SERVER_PROTOCOL'], '/')));
$url = $protocol.'://'.$_SERVER['HTTP_HOST'].base_path().implode('/', $_GET);
$block['content'] = theme('service_links_block_format', service_links_render('', '', $url));
}
return $block;
}
?>
find function service_links_render() - it should be the next one down
replace the function arguments with:
<?php$node, $nodelink = FALSE, $page = FALSE
?>
remove everything up to the line:
<?phpif (variable_get('service_links_show_delicious', 0)) {
?>
and in front of the same line place:
<?php
$links = array();
if($page)
{
$url = $page;
$title = drupal_get_title();
}
else
{
if(variable_get('service_links_agg2_link', 0) && $node->link)
$url = ($node->source_link ? $node->source_link : $node->link);
elseif(!empty($node))
$url = url("node/$node->nid", NULL, NULL, TRUE);
else
$url = url($_GET['q'], NULL, NULL, TRUE);
$url = urlencode($url);
$title = urlencode($node->title);
}
?>
... and you should be good to go :)
#7
Wow, thank you very much for this patch. I was getting a bit irritated by the fact that I could not see service links on my frontpage and category pages after putting it in as a block :)
Will try this solution now and I hope this gets committed to the module.
#8
I just did it, and it works except it still does not show on my frontpage :)
Any ideas?