Active
Project:
Facebook Share
Version:
6.x-1.0
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
31 Jul 2010 at 13:44 UTC
Updated:
7 Oct 2014 at 06:11 UTC
Jump to comment: Most recent
Comments
Comment #1
lolandese commentedThis solution is independent from the Facebook Share module and supposes the use of URL aliases. I use the module for the single nodes and the code below for the views.
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>The result is a FB share button that points to the intended node for each displayed node in the view. Would be nice if you have an image in the node content. This will allow the user to display it together with some text on their FB stream.
A working demo.
More info on Facebook.
The credit for this solution goes to this node.
One thing I gave a quick look but didn't manage to do yet is this (quote from Facebook):
These meta tags should of course be added to the <head> element of the node. Any suggestions?
If instead you want the share widget to show on nodes that use panel pages, go here.
Comment #2
summit commentedSubscribing, greetings, Martijn
Comment #3
benjifisherThanks for the explanation! I did it slightly differently:
<javascript>went.drupal_get_path_alias.I was going to say that
$targetPathshould be url-encoded, but Drupal seems to do that automatically. :)For the Facebook-friendly
<meta>tags, I have not tried anything, but Nodewords looks like the right tool, or maybe Simple Meta. Or you can edit your theme's node.tpl.php file.Comment #4
lolandese commentedOff topic
Nodewords and Simple Meta don't support the Open Graph protocol meta tags YET (the one used by FB). Probably it's only a matter of time before at least Nodewords does (already a feature request there). For now I use a slightly tweaked version of this. It should be committed it in a real module. Ideal would be integration in the Nodewords module (or the newly under development Meta tags module).
Comment #5
rumblewand commentedAwesome! This worked for me (using drupal for facebook) to pass the Like button into my collection of frontpage content with a mix of nodes.
Comment #6
rickh commentedlolandese. thanks this works for nodes bit can you tell me how to odify the code for the My Accoutn page so to insert this into the users profile?
Comment #7
lolandese commented@ rickh: Make a new block:
Block body:
Input format: PHP
Page specific visibility settings: Show only on the listed pages: user/*
Put it in one of the top regions of your theme.
No need to use Views, just a plain block will do. With this code also the Share button of a single node can be handled (not a View that displays several nodes). In that case substitute user/ with node/.
Don't forget to enable the optional core module "PHP filter" to have the PHP input format available.
Comment #8
freeform.steph commentedIf your site has multiple views, it would be beneficial to add a block that can be shared amongst those pages without having to add code in the header or footer of each view. In that case, as above, create a new block with display option set to specific pages, and then use the code above, changing:
$targetPath = url('user/'.drupal_get_normal_path(arg(1)), $options); print $targetPath; ?>"to:
$targetPath = url(drupal_get_normal_path(arg(0)), $options); print $targetPath; ?>"Comment #9
norman.lolThanks #1, helped me a lot to find out how to use the 2013 code for a dynamic Facebook Share button (the one with the popup window), inside a view with a custom php field and its availabe variables. In the 'output code' field I then wrote:
Comment #10
szt commented