Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm not code-smart, so I apologize in advance if this is obvious. But is it possible to pull Facebook like data into views? Right now I'm using the flag plugin with views to allow users to flag nodes as recommended, but I would like to be able to have them use the Facebook "like" button only, and then let me use that data in views (ie. show counts of how many people like something, create a block showing the most recently "liked" nodes, etc)
Comment | File | Size | Author |
---|---|---|---|
#46 | fb-social-views-815568-46.patch | 4.58 KB | acouch |
#45 | fb-social-views-815568-45.patch | 3.42 KB | ferdi |
#43 | fb-social-views-815568-43.patch | 4.62 KB | acouch |
#36 | fb-social-views--815568-36.patch | 1.41 KB | acouch |
#32 | fb-social-views-815568-32.patch | 18.24 KB | acouch |
Comments
Comment #1
ferdi CreditAttribution: ferdi commentedGreat idea. Here is what I think could work: Make the like button a cck field, integrate it with some existing drupal voting modules (i.e. votingapi) and intercept the click using fb javascript api (http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe). Hope I find some time to try this out in the next couple of days.
Comment #2
jdblank CreditAttribution: jdblank commentedHi, I also have a need to be able to display the like button on individual items in a list from a view. Did you have any luck getting this to work?
Comment #3
egarias CreditAttribution: egarias commentedMy problem is with comments.
When using the comments, they are not accesible throught views, only the old comments (no Facebook) are shown.
My question is how can i access those comments, maybe some php code?.
Will you plan to integrate comments with views if they are not?
Thanks
Enrique
Comment #4
ferdi CreditAttribution: ferdi commentedThe original ticket is about integrating number of fb likes with views. There is one thing that makes it hard to implement. Currently facebook allows users to undo their "like" (unlike) but there is not a javascript event associated with unlike.
@jdblank you can use views already to show node teasers which contain the like widget.
@egarias Facebook comments are not saved locally in the database. Please open a new ticket if you are asking for integration of fb comments with drupal.
Comment #5
liquidcms CreditAttribution: liquidcms commentedalthough yes, you can do your View as a list of teasers and therefore show the like button that way; ideally we could make field views (as they are much more powerful than teaser views) and would then have a "field" that was the like button that we could add.
Comment #6
walden CreditAttribution: walden commented@liquidcms I totally agree with you, it would be incredibly useful to be able to access the FB like button as a field in views.
Has anyone come up with an interim solution besides using the teaser style?
Comment #7
eyenology CreditAttribution: eyenology commentedsubscribe
Comment #8
ferdi CreditAttribution: ferdi commentedHere is some code that integrate fb like button with views i.e. fb like will be one of the available fields in your view. http://drupal.org/cvs?commit=410224 .It would be great if someone can test it.
Thanks.
Comment #9
liquidcms CreditAttribution: liquidcms commentedi'll test. any chance you can post a zip or something a little more accessible that whatever the link above goes to? :)
Comment #10
liquidcms CreditAttribution: liquidcms commentedhmm.. ok, i think you are just saying it is the latest dev release as it looks like that has the views.inc file
i'll test first thing in the morning. thanks a ton.
Comment #11
liquidcms CreditAttribution: liquidcms commenteduh nope, doesn't work.. as far as i can tell anyway.
to start with this breaks the attachment i had that was adding the teaser view to my fields view (but if this worked; no big deal)
i see when i am adding a field and trying to filter the list that there is a fb social button listed at the end (this is the actual field though and should be the group "FB Social" or something like that). selecting this does not do any filtering.
but without filtering i can still see the fb social button listed at the bottom... when i add the field i don't get any thing added to my fields list BUT i do see the label "fb social like button: " added to my output.
Comment #12
ferdi CreditAttribution: ferdi commentedIt should provide the functionality described in #5 and #6 . Here is a simple view that i'm using for testing. Import & save the view and then visit yoursite.com/fbviewtest
thanks for testing !
Comment #13
ferdi CreditAttribution: ferdi commentedComment #14
minus CreditAttribution: minus commentedThank you very much for the effort you have been putting into this module ferdi!!
I tested your view, it gives me a list of nodes and a like button for each field. I tried to sort this view by the number of times the like button had been clicked, but there are no options for that in my sort options list.
A nice feature would be a statistics option, so that you can create a block with most liked, most shared and most commented (if this is possible it would be really nice.)
Node title (89) where 89 is the number of users who has clicked the liked button (I guess you knew what I ment :p)
Morten
Comment #15
liquidcms CreditAttribution: liquidcms commentedyay.. it does seem to work!! it doesn't show in the Views preview but once i saved; it does show on the site.
thank-you.. this sure helps a lot.. :)
Comment #16
liquidcms CreditAttribution: liquidcms commentedalthough, for some odd reason the colour selector when adding the button as a views field doesn't do anything. i mean i can select it and see the options.. but picking one doesn't change it from the default of Dark.
Comment #17
lee20 CreditAttribution: lee20 commentedThe like button doesn't "like" the right URL. Here is the diff that fixes this:
Comment #18
chia CreditAttribution: chia commentedsubscribe
Comment #19
alexmartin CreditAttribution: alexmartin commentedThanks for your work on this Ferdi. I've got this working using the view supplied above. However, I'd also like to display the 'share' button, share count and comment count in the view (comment count being the most important to me). Is there any way you know to achieve this?
Thanks again,
Alex
Comment #20
Roavei CreditAttribution: Roavei commentedWorks like a charm. But there is missing a "exclude from display" checkbox :|
Comment #21
Amir Simantov CreditAttribution: Amir Simantov commentedHi guys,
It seems that you are dealing here mostly with Like button, right? What I need is to show the fb comments in a view when using the node row style. Is there any solution for this?
Great module, thanks!
Comment #22
rumblewand CreditAttribution: rumblewand commentedHey everybody I did some digging and found #870262: Using FS with Views for a diff mod that enabled me to pass the php code into a views field so that the fb:like like button is posted AND the appropriate node address is passed to it.
I'm using Drupal for Facebook and I was making a frontpage view of events and general we posts. Works like a charm!>
Comment #23
rumblewand CreditAttribution: rumblewand commentedOh and @Amir you can probably adjust the code in that example to use the xfbml for comments. You might want to open an issue over at the drupal for facebook module.
Comment #24
Oscar Illada CreditAttribution: Oscar Illada commentedI was looking for the functionality too, to put in a view the top liked nodes. Is there a possibility?
Comment #25
Oscar Illada CreditAttribution: Oscar Illada commentedFind my solution thanks http://drupal.org/project/views_fb_like
Comment #26
vin247 CreditAttribution: vin247 commentedI think the code by lee20 should get more notice (if it hasn't already)...I was having trouble with the like button when used in a view (it wasn't outputting the link correctly) and adding the line: 'href' => fb_social_url('node/' . $values->nid), it now works perfectly!
Comment #27
ferdi CreditAttribution: ferdi commented#17 is committed http://drupal.org/cvs?commit=473098. Thanks!
Comment #28
YK85 CreditAttribution: YK85 commentedsubscribing - is there any further development happening here or is this status 'fixed'?
Comment #29
ferdi CreditAttribution: ferdi commentedwe dont have anything better than #25 for now.
Comment #30
Júlio Boaro CreditAttribution: Júlio Boaro commentedSubscribe
Comment #31
dafederHere's one solution for 7.x. Add an "nid" field to your view, as well as a Content Type field that is hidden. Copy views-view-field.tpl.php template to your theme directory, and add the following to template.php, correcting for theme, fb_social preset, and view names:
I'm sure something similar could be done for 6.x.
Would of course be nice to have a field available right in views. Wouldn't be too hard but don't have the hours to devote to it at the moment, as this is working well for me for now.
Comment #32
acouch CreditAttribution: acouch commentedI created a views handler for this which adds a global field that allows you to add an already created preset.
Unfortunately if it is being displayed on a page where it is referring to another page (on a list of teasers for example) it requires the nid for the node in the row. The nid is only available if some field from the node column is added. So this will work on a teaser as long as there is a node title, body, teaser, field etc.
That limitation seems like a blocker however for a module that may have a lot of new users using it. I'm attaching anyway in case someone wants to use this or it doesn't seem as bad a limitation as I fear.
Comment #33
kiranjyoth CreditAttribution: kiranjyoth commentedI tried to do this, but i am getting some errors. May be you could help me. Here are the steps i followed.
1. Copied views-view-field.tpl.php from views module's theme folder to my theme directory
2. Edited and added the code that you provided to the template.php file. I changed the theme name, view name and preset name ( in this case, my preset name is 'like')
3. Added nid field to the fields
4. added a content type field and excluded it from display.
I get the following error message
Notice: Undefined property: stdClass::$node_type in corporateclean_preprocess_views_view_field() (line 75 of /home/devnode/public_html/sites/all/themes/corporateclean/template.php).
Notice: Undefined index: fb_social_like in corporateclean_preprocess_views_view_field() (line 80 of /home/devnode/public_html/sites/all/themes/corporateclean/template.php).
Notice: Undefined property: stdClass::$node_type in corporateclean_preprocess_views_view_field() (line 75 of /home/devnode/public_html/sites/all/themes/corporateclean/template.php).
Notice: Undefined index: fb_social_like in corporateclean_preprocess_views_view_field() (line 80 of /home/devnode/public_html/sites/all/themes/corporateclean/template.php).
Can you help me with what I am doing wrong here?
Comment #34
acouch CreditAttribution: acouch commentedI have this fixed but haven't updated this yet. Will do so shortly.
Comment #35
kiranjyoth CreditAttribution: kiranjyoth commentedPlease do! Thanks for the quick response!
Comment #36
acouch CreditAttribution: acouch commentedAttached is a patch that provides views support for users and node tables. I fixed the alias issue I was having and re-rolled versus the recent commits.
The url changes for each node or user for like, facepile, comments, and send plugins (the only plugins that wil accept the href option). If one of those is not chosen it just displays the plugin as normal.
This could be extended to other entities like taxonomy etc if requested.
Comment #37
acouch CreditAttribution: acouch commentedPlease give it a test.
Comment #38
wiherek CreditAttribution: wiherek commentedtried it, it works with comments (yeah! :)). The patch does it all, theres no need for the solution from #31 (which I couldn't reproduce)
Issues found:
1. MAJOR - there is no views field for the comments preset, or any other fb social preset, which made me have to render the views by 'content' which is annoying if only used on a blog, and a 'blockerer' when used with more specific views
2. when the content was rendered without showing links or comments, and the window width was somewhat narrow (??), this error showed up:
Notice: Undefined variable: nr_comments in _fb_social_comments_comments_count() (line 235 of /(...)/sites/all/modules/fb_social/plugins/fb_plugin/comments.inc).
except for that it works fine. By the way, I added a href field for the like button some time ago (very simple). will add that to git sometime soon.
Comment #39
acouch CreditAttribution: acouch commentedhi @wiherek5
Thanks for your comments. For:
| 1. MAJOR - there is no views field for the comments preset, or any other fb social preset,
The steps for this to work with comment #36 are to:
1) Create the fb_social preset which you wish to use in a view.
2) Create a view with 'content' or 'user' as the base table.
3) Add the "Facebool Social" preset field which will be in the "Node" or "User" group in the view.
For:
| 2.
That is an issue unrelated to views support. I've created a separate issue #1371416: Undefined comment property in _fb_social_comments_comments_count()
Comment #40
kiranjyoth CreditAttribution: kiranjyoth commented#36 @acouch, This patch worked for me. Thanks!
Comment #41
wiherek CreditAttribution: wiherek commented@acouch: I still can't see the field.
What I did was: just installed the module, without following #31.
I create the view, showing content of type 'article', created as a page. I save and get to the view edit screen. The default way that view is rendered is 'content', which doesn't allow adding new fields (it uses the fields from the content type). That way, the fb_social is shown, I can add comments.
However, if I change the way the view is rendered to 'fields', and try to add a new field, there is no "Facebook Social" preset field neither in the 'node' group, nor 'user' (when creating a view showing users).
This is views3.
Comment #42
ferdi CreditAttribution: ferdi commentedIs plugins/views/fb_social_handler_field.inc missing in #36?
Instead of changing the signature for fb_social_preset_view(), can we use theme_fb_social_plugin ?
Comment #43
acouch CreditAttribution: acouch commented@ferdi, you are correct, patch in #36 was missing that file. I rerolled.
For using theme_fb_social_plugin() vs. fb_social_preset_view() I would argue that since we adding data to the output that that should happen before the theme function if possible.
@wiherek5 can you re-try? Thanks!
Comment #44
wiherek CreditAttribution: wiherek commentedit works now. thanks!
Comment #45
ferdi CreditAttribution: ferdi commented@acouch
How about something like this? Adding an url argument to fb_social_preset_view() feels a bit strange so I'm trying to avoid that.
Comment #46
acouch CreditAttribution: acouch commentedThat looks good. I noticed that you missed the fb_social.views.inc in your patch so I re-rolled.
Comment #47
ferdi CreditAttribution: ferdi commentedCommitted http://drupalcode.org/project/fb_social.git/commit/71e500f
thanks everyone !!!
Comment #48
ferdi CreditAttribution: ferdi commentedUse fb_social_url to construct the 'href' attribute http://drupalcode.org/project/fb_social.git/commit/8ecdb9c
And backported for 6--2 branch http://drupalcode.org/project/fb_social.git/commit/5e680af
Comment #50
heyyo CreditAttribution: heyyo commentedIs there a filter to content which has been liked or commented ?
Comment #51
heyyo CreditAttribution: heyyo commentedComment #52
raidcha CreditAttribution: raidcha commentedHi
Like heyyo, i'm interested in a view sort criteria or filter to get the most commented or liked node