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

Comments

wayland76’s picture

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

Do you have a link we can see?

apsivam’s picture

Status: Active » Postponed (maintainer needs more info)

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

luke76’s picture

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.

jenlampton’s picture

Category: support » feature

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

wayland76’s picture

Title: Service links block not showing » Show links on non-node pages
Component: User interface » Code
Status: Postponed (maintainer needs more info) » Active
yuriy.babenko’s picture

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:

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:

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:

$node, $nodelink = FALSE, $page = FALSE

remove everything up to the line:

if (variable_get('service_links_show_delicious', 0)) {

and in front of the same line place:

$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 :)

giorgio79’s picture

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.

giorgio79’s picture

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

Any ideas?

wflorian’s picture

this is great. but i have one problem. one a views page, it doesn't show the url alias, instead it shows taxonomy/term/6 for example. is there a possibilty to use the url alias instead? i would be really thankful if somebody could find a solution!!

florian.

EDIT: it does not matter if the page is a views page. this happens on all taxonomy term pages. on these pages the url alias is not shown with the service links, instead urls like taxonomy/term/X

wflorian’s picture

No idea anybody??

jenlampton’s picture

@ wflorian,

you should be able to get around this problem by using the url function... from the code above, replace this...

$url = $protocol.'://'.$_SERVER['HTTP_HOST'].base_path().implode('/', $_GET);

with this...

$url = url(implode('/', $_GET));

The url function adds all those other bits, and also checks for aliases in the system.

Please note: I have not tried this, but it should work. if it doesn't you can also try something like...

$url = $protocol.'://'.$_SERVER['HTTP_HOST'].base_path().drupal_get_path_alias(implode('/', $_GET));

...but that should be a last resort.

Good Luck!
Jen

wflorian’s picture

Hey Jen,

thank for looking at my problem.

$url = url(implode('/', $_GET)); didn't work right, when using this, it just showed the url-alias without the domain-name!

$url = $protocol.'://'.$_SERVER['HTTP_HOST'].base_path().drupal_get_path_alias(implode('/', $_GET)); works absolutely perfect!

Thank you for that!!!!

Florian.

jenlampton’s picture

My concern arises because you really shouldn't ever need to tell drupal to add the protocol or the host. In fact, url is supposed to return base_path as part of it's result... did you set the $base_url variable in settings.php?

something about appending base_path to $_SERVER['HTTP_HOST'] seems wrong to me.

If it were me, I'd adjust settings.php and try to get something working with url.

wflorian’s picture

hmm i just tested the code on my localhost. maybe on my webserver the other code would also work...

jenlampton’s picture

Well if it's good code, it should work in both places.

What url does is take base_path() and then tack url-encoded results of drupal_get_path_alias() on to the end of it. So there's no reason that shouldn't work.

I still think your issue is around base_path, and if your links work right on your dev server without base_path returning anything, then they will certainly be broken on your live site if it does return something.

Food for thought.
Jen

xjessie007’s picture

Just a thought, have you selected categories in Administration -> Service Links? In addition to enabling the block in Administration -> Blocks, you also have to define where you want to display the block in the Service Links config.

In regards to positioning Service Links, here is more info from other post I just wrote:

Re: i'm trying to print the service links at the top of the page, underneath the title.

There are two functions in service_links.module.

The theme_service_links_node_format() is responsible for theming the output when it is appended to the node.

The theme_service_links_block_format() function themes the content if you display it as a block.

hook_block() is where the output is passed to Drupal.

For some reason, if you enable block display, service links gets displayed at both places - appended to the node and in the sidebar block too. So, if you want to display the service links as a block but not in the sidebar but let's say at the top of the post (and you want to turn off displaying service links at the end of a node too), you need to modify these functions here a little.

Uncomment everything from inside of theme_service_links_node_format. This will stop displaying service links at the end of a node.

Because theme_service_links_block_format displays the service links as UL-LI by default which is ok for sidebar block but not very nice for a top/bottom content block, you need to modify theme_service_links_block_format. I probably did not do it the best way, but I think it was the easiest way. I used the strip_tags($a, 'div a img') function to just strip all but a, div, img HTML tags from the already themed output.

Now you just enable your block and position it to content top or whereever you like. Works fine.

Note, here are other Drupal thread related to the same or similar problem:

http://drupal.org/node/257361
http://drupal.org/node/288612
http://drupal.org/node/214939

__________________
Drupal cache clean up - cache_clear_all()
How to delete or clear Drupal cache tables?

joachim’s picture

+1
subscribing.

Any chance of this being in the next release?

joachim’s picture

Regarding the url / $GET debate -- read the API docs!
url() can be made to give a complete URL including the protocol, like this:

        $url = url(implode('/', $_GET), NULL, NULL, TRUE);
fleshgrinder’s picture

I always had the URL http://www.example.org/node within my frontpage, so I created the following:

/**
 * Implementation of hook_block().
 */
function service_links_block($op = 'list', $delta = 0, $edit = array()) {
  if ($op == 'list') {
    $blocks[0]['info'] = t('Service links');
    return $blocks;
  }
  else if ($op == 'view') {
      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));
        }
        elseif(drupal_is_front_page()) {
          $protocol = strtolower(substr($_SERVER['SERVER_PROTOCOL'], 0, strpos($_SERVER['SERVER_PROTOCOL'], '/')));
          $url = $protocol.'://'.$_SERVER['HTTP_HOST'].base_path();
          $block['content'] = theme('service_links_block_format', service_links_render('', '', $url));
        }
        else {
          $protocol = strtolower(substr($_SERVER['SERVER_PROTOCOL'], 0, strpos($_SERVER['SERVER_PROTOCOL'], '/')));
          $url = $protocol.'://'.$_SERVER['HTTP_HOST'].base_path().drupal_get_path_alias(implode('/', $_GET));
          $block['content'] = theme('service_links_block_format', service_links_render('', '', $url));
        }
      return $block;
    }
  }
}

Maybe this is useful for anyone.

Kindest regards
Fleshgrinder

quotientix’s picture

Thanks fleshgrinder, your version is showing me the service links on the front page, but not on the regular nodes.

On the original module it's the other way round.

Any ideas on how to show the service links on both?

Thanks!

TheCrow’s picture

Read this issue for non-node pages and keep using the original block for node pages, or combine the two... many ways.

byant’s picture

I am newbie here,
could you tell more detail how to put this function strip_tags($a, 'div a img') to get top/bottom block work with service links?

thanks

okokokok’s picture

Version: 5.x-1.1 » 6.x-2.x-dev

Still relevant today on 2.x-dev.

span’s picture

Thanks you Fleshgrinder, this is a crucial issue in my opinion...together with larger icons of course :]

Thanks for a great module.

mark.’s picture

Does anyone have any tips on how to make fleshgrinder's code work when the homepage is set to user/register?

Melissamcewen’s picture

subscribe

TheCrow’s picture

Status: Active » Fixed

Feature Added!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

knalstaaf’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev
Issue summary: View changes
Status: Closed (fixed) » Active
knalstaaf’s picture

Status: Active » Closed (fixed)

Hmm, will close this one again for tidiness sake.

knalstaaf’s picture

Version: 7.x-2.x-dev » 6.x-2.x-dev