I am trying to use flags module with Drupal for facebook. I want to display only nodes that are flagged by facebook friends of current user. Flag module provides only "Any User" and "Current User" as filter options for "Is Flagged By" in the view. I would like "Is Flagged By" -> "Facebook friend" as an option.
Any ideas how I can do this? I am fine with modifying the php code. Need some directions on what needs to change.
Thanks in advance!
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | flag.views_.inc_.txt | 15.47 KB | vssaokar |
| #7 | flag.views_.inc_.txt | 15.84 KB | vssaokar |
Comments
Comment #1
Dave Cohen commentedwriting argument and filter handlers for views is failry involved. You can find reasonable doc for it on drupal.org. Look at fb_views.module for an example. It defines an argument handler which limits a view to nodes authored by friends of the given user.
If you get it working, please post the code here. It might help others define similar filters.
Comment #2
vssaokar commentedI made the change to flag views code to handle this. There are some issues and I need to debug.
Question: how do I see the db queries when running the app thru facebook? I have enabled Devel module.
Comment #3
Dave Cohen commentedI just tried enabling the devel query log, and it appears fine on canvas pages as well as regular pages. Is that what you're talking about?
Comment #4
vssaokar commentedThat is right. I see the queries in regular pages and not on canvas pages. I have enabled devel query log. Any ideas?
Comment #5
Dave Cohen commentedWhen you view the canvas pages, you're probably a user without permission to view devel info. Try letting all users (anon and registered) see devel info.
Comment #6
vssaokar commentedExcellent! That did it. thanks.
Comment #7
vssaokar commentedDave,
I modified the flag.views.inc to add the filter code. But I am getting the following SQL error,
Unknown column 'fb_user_app.fbu' in 'where clause' query: pager_query SELECT count(node.nid) FROM node node LEFT JOIN flag_content flag_content_recommendmovie ON node.nid = flag_content_recommendmovie.content_id AND flag_content_recommendmovie.fid = '2' LEFT JOIN flag_content flag_content_recommendmovie2 ON node.nid = flag_content_recommendmovie2.content_id LEFT JOIN users flag_users_recommendmovie ON flag_content_recommendmovie.uid = flag_users_recommendmovie.uid WHERE (node.status = '1') AND (flag_content_recommendmovie.uid IS NOT NULL) AND (fb_user_app.fbu IN (1229240,500082917,508457230,518038926,533871278,540043831,541288400,552380769,560771745,585053032,592421364,592597736,603769327,613170792,625116962,628460171,637250521,641933284,642386762,643723853,645496843,647012462,649222115,657949364,670921669,671761112,684362532,688395307,692991684,694089967,697816227,706755587,709846800,710893008,727800851,728955437,737754310,776357989,1035296673,1064457289,1067418725,1204913164,1233981813,1424152757,1477177102,1507380422)) AND (node.nid = 488) in /home/9a0440c5/web/public/includes/database.mysql.inc on line 174.
I am attaching the flag.views.inc code. For some reason, fb_user_app is not getting added to the join.
Any ideas?
Comment #8
Dave Cohen commentedITs a matter of getting views to add fb_user_fbu to the join clauses. I'm not expert enough to tell you exactly how. Coding for views is tricky.
Comment #9
vssaokar commentedI made change to flag views code to handle this. Attached is the code for anybody interested.
Example Usage : "Recommend Movie" flag on CCK type "Movie". View to show only your facebook friends who recommend this movie. In the flag filter section, " 'Is Flagged By' has this additional option now - 'Facebook User: Author is Friend'
Comment #10
foxfabi commentedextending drupal for facebook fb_friends using drupal flag_friends ...
i build a function that flag all facebook friends that have added the application as drupal 'friends':
to check if a user has new appz friends you call:
More info or troubleshooting:
Comment #11
joshuabud commentedI'm simply trying to offer the ability to flag a module with no specific views and I get a really long error pop-up when I click the flag I have created.
I have no idea where to even begin. What a drag as this is a major functionality of the facebook app.
Comment #12
Dave Cohen commentedJoshuaBud, where to begin is that the flag module should probably use a URL that starts with http://your-site.com, and not http://apps.facebook.com/... I don't know much about the flag module, so I can't say how it passed URLs around.