By haopei on
Hello everyone,
I would like to embed a Facebook like widget inside a view.
The problem is this: The 'like' widget, when embedded, takes the currently url of the page being viewed. If I embed the widget's code (see below) directly inside a view, the widget will take the URL of the currently viewed page INSTEAD of the url of the item inside the view.
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=214574488595179&xfbml=1"></script><fb:like href="" send="true" width="450" show_faces="true" font=""></fb:like>
I have also tried to use tokens to replace the url:
<fb:like href="[path]" ...
This was unsuccessful. Does anyone have any ideas?
Comments
.
Did you try this ?
<iframe src="http://www.facebook.com/plugins/like.php?app_id=115090841922001&href=[node:url]&send=false&layout=standard&width=450&show_faces=true&action=like&colorscheme=light&font&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>This is just a code I used in a small Drupal site's View.
You need to use the exact URL (not [Path], I guess) of the URL you need to "like".
I think, the problem is, Facebook got the path(say "comment/reply/1241016" ) and failed back to current URL.
What's new and changing in PHP 8.4
Hi Ayesh, This doesn't seem
Hi Ayesh,
This doesn't seem to work. I do not believe the view understands the [node:url] token.
Is there any way to use php to get the node url of each item in a view? If so, I can do this:
.
The code you are mentioning is XFBML markup.
To get node's URL, use Node:link field and use it's token. Sorry for not specific about that.
What's new and changing in PHP 8.4
I have actually tried this. I
I have actually tried this. I think the problem is that fbml will not translate drupal tokens, so it literally outputs [node: link] as its href value.
I have tried replacing the href value with a php print code, and it seems to be able to translate php. So one solution might be to use php to get the current path and embed it as the href value.
Please let me know if there
Please let me know if there is a way to accomplish this. It is very important for my site.
Thanks
^
Rethinking.
Install http://drupal.org/project/views_customfield and apply http://drupal.org/files/issues/views_customfield.patch
Then you'll be able to add custom fields and tokens in the View(patch is not needed if you are comfortable with the module and node objects.)
Create a View taking Node table, add 2 fields(node: path and custom field:PHP code).
Now, hide the node:path field and in PHP code field, add the following.
<iframe src="http://www.facebook.com/plugins/like.php?app_id=115090841922001&href=<?php print $base_path/[node:path]; ?>&send=false&layout=standard&width=450&show_faces=true&action=like&colorscheme=light&font&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>(the patch will replace tokens in the code with actual values beforerunning the PHP code.)
Note: Please do not use this code as-is. I just borrowed code from facebook developer help page when I'm logged in. So most likely that "?app_id=115090841922001" part is "mine property".
Replace [node:path with actual path field's token.]
What's new and changing in PHP 8.4
Dang. I wish I was running
Dang. I wish I was running 6x. Right now I am running 7x so won't work for me. Thanks for the help though.
Is this any help to your
Is this any help to your situation for version 7 http://drupal.org/project/views_php ?
I have never installed a
I have never installed a patch because I am fearful of breaking my website. Someone should develop this little feature.
resolved?
I need this feature too. I'm finding a solution for days but with no results. Have you resolved? if yes, how?
I'm using 7.x version.
Thanks
I haven't found a solution
I haven't found a solution yet edubacco.