I cannot get the share widget to show on node pages that us panel pages.

I have looked in widgets and miscellaneous in the panel page content categories.

How can I add this to panel pages?

Comments

JeniferTucker’s picture

Having the same problem... anyone help? Assumed it would appear in the 'widgets' to select from.

lolandese’s picture

A temporary work-around independent from the module.

  • Goto your Panel node template (on a node Edit panel then Edit content)
  • At top of the desired area, click the setting icon to Add content
  • In the left column click New custom content
  • Give it an administrative title, e.g. FB Share button
  • Put this code in the body field:
    <a name="fb_share" type="button" share_url="<?php
    $targetPath = 'http://'.$_SERVER['HTTP_HOST'].base_path().'node/'.drupal_get_normal_path(arg(1));
    print $targetPath;
    ?>" href="http://www.facebook.com/sharer.php?u=<?php
    print $targetPath;
    ?>">Share</a>
    <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
  • Change the input format to PHP (activate first the optional core module PHP filter) and save
  • Drag and drop the newly created pane in the desired position, update and save the panel
  • Open a node and check the result.

Next step would be to use the URL alias instead of the nid. Any suggestions?

A working demo.
If instead you want to generate a FB button in a View, go here.

Summit’s picture

Subscribing, anyone has a native panels solution?
greetings,
Martijn

itserich’s picture

This button looks great but I also use panels.

baff’s picture

I tried the code in #2 - but I think there is a bug in it

lolandese’s picture

@ baff: More specifically?

baff’s picture

It is working. had to manually clean the code after pasting - this comes I think with the copy and paste procedure where some spaces get lost.

boardyuk’s picture

Version: 6.x-1.0 » 7.x-1.3

I know it's been a while since this was last posted in but just thought I'd share how to get URL aliases working in the buttons, I'm using a modified version of #2 with the code being as follows -

<a name="fb_share" type="button" share_url="<?php
$options = array('absolute' => TRUE);
$targetPath = url('node/'.drupal_get_normal_path(arg(1)), $options); print $targetPath; ?>" href="http://www.facebook.com/sharer.php?u=<?php print $targetPath; ?>">Share</a>
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>

That uses Drupals url() function to find the alias of the node.

Simple really :-)

lolandese’s picture

#8: Tested. Also in D6 it works. Thanks for sharing. Enjoy the blue, Boardy.

matteblacke’s picture

This is killing the Javascript for a Google maps CCK (Gmaps) on the same page, any idea why?

matteblacke’s picture

Using Jquery to append the script tag seems to have fixed the problem, no idea why though

$('head').append("");
eidoscom’s picture

Better if you use this code:

<a name="fb_share" type="button" share_url="<?php
$options = array('absolute' => TRUE);
$targetPath = print url('node/%node:nid');
?>" href="http://www.facebook.com/sharer.php?u=<?php
$targetPath;
?>">Share</a>
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>