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
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

wayland76 - February 26, 2008 - 01:25

Where have you positioned the block in the Blocks admin settings?

Do you have a link we can see?

#2

apsivam - February 26, 2008 - 16:37
Status:active» active (needs more info)

cannot reproduce here. can you provide more information about your setup/configuration ?

#3

luke76 - February 27, 2008 - 14:39

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

jenlampton - May 29, 2008 - 20:29
Category:support request» feature request

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

wayland76 - May 30, 2008 - 03:37
Title:Service links block not showing» Show links on non-node pages
Component:User interface» Code
Status:active (needs more info)» active

#6

yuriy@yuba - May 30, 2008 - 17:13

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:

<?php
if (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

giorgio79 - July 27, 2008 - 05:25

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

giorgio79 - July 27, 2008 - 05:31

I just did it, and it works except it still does not show on my frontpage :)

Any ideas?

 
 

Drupal is a registered trademark of Dries Buytaert.