fb_form path fb/invite completely broken in D6

neilnz - July 15, 2009 - 22:28
Project:Drupal for Facebook
Version:6.x-2.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Dave Cohen
Status:closed
Description

Hi,

While it seems fb_form was ported to Drupal 6, it doesn't work at all. It looks like there was supposed to be some shift from fb_form_request_selector to fb_form_multi_friend_selector that didn't happen...

At any rate there's theme functions such as theme_fb_form_request() that are lost because they're not referenced in hook_theme(), and when fb_form_invite_page() calls drupal_get_form('fb_form_multi_add_invite_form') it just returns null because Drupal can't find theme functions for theme keys 'fb_form_request_selector' and 'fb_form_request'.

I had a go at patching it up, but was unable to figure out what was deprecated and what was the new way. I haven't managed to get it to work yet.

I suspect this functionality was overlooked in the D6 port?

Sorry I can't offer a patch. I normally would, but I don't understand the workings of this module enough to do so.

#1

Dave Cohen - July 16, 2009 - 00:26
Priority:critical» normal
Assigned to:Anonymous» Dave Cohen

There are a number of things to clean up, in several modules including this. And the time has come. I'll do my best to take a look this week or early next and I'll let you know. (and get some other patches checked in at the same time).

I think the future of invite forms lies in contrib/fb_friend.module.

I appreciate the effort.

#2

ahansen1 - September 9, 2009 - 00:27

I've started playing with the fix for this. I have the form returning, but it still doesn't show in the FBML. The only change I made was from:

$output = drupal_get_form('fb_form_multi_add_invite_form');

To:

$output = drupal_get_form('fb_form_multi_add_invite');

I can now see the form being output in the FBML debug, but it isn't showing the form on the page. My guess is there is still something missing with generating the proper FBML. Anyone else have any luck with this?

#3

Dave Cohen - September 24, 2009 - 15:24
Category:bug report» support request
Status:active» needs review

OK, finally some time to describe this... In upgrading to D6 I'm changing the way invite forms are supported. To be more consistent with the way Drupal generally works, the idea now is to create a data structure representing the markup, then drupal_render() it.

See fb/contrib/fb_friend.module. Specifically the code responsible for the FB_FRIEND_DELTA_INVITE_PAGE block. Currently, fb_friend.module works only on Facebook Connect pages. But the goal is to support canvas pages eventually. So try to use fb_friend.module instead of writing your own, but if that fails use it as an example.

fb_friend currently provides two blocks. One will invite users to visit the current page. The other invites users to add the application. Try adding the "invite to current page" block to the footer of a Facebook Connect page. You should see a big invite form embedded within the page.

You can tweak various aspects of this form by implementing hook_fb_friend_invite_page_alter(). (It's really a drupal_alter function, slightly different from a hook, but you know what I mean.) The data structure you're altering represents the form described on http://wiki.developers.facebook.com/index.php/Fb:request-form, so read up there and use function like dpm() to inspect the data.

#4

Dave Cohen - September 24, 2009 - 15:27

And here's one more trick...

If you want to render the invite form in a popup, use hook_fb_friend_invite_page_wrap_alter(). Sure, all the hooks and data structures seem a little crazy. But it's very flexible and I believe true to the Drupal Way.

Here's code that will provide a link that pops up the invite form. In this way you can make the block fit in a sidebar, for example.

<?php
/**                                                                            
* Implementation of hook_fb_friend_invite_page_wrap_alter().  See fb_friend.mo\
dule.                                                                          
*                                                                             
* Here we customize the block which invites facebook friends to visit         
* the current page.                                                           
*                                                                             
* By default the invite form is wrapped in serverfbml and embedded            
* within a page.  Here we alter the data before it is rendered.  We           
* change the wrapper type to fb_connect_fbml_popup.  The result is a          
* link which pops up the invite form.                                         
*/
function hook_fb_friend_invite_page_wrap_alter(&$elem) {

 
// Replace serverfbml with popup                                             
 
if ($elem['#type'] == 'fb_form_serverfbml') {
   
$elem['#type'] = 'fb_connect_fbml_popup';
   
$elem['#title'] = t('Invite Friends');
   
$elem['#link_text'] = t('Invite Friends');
   
$elem['#attributes'] = array('width' => 760);
  }
}
?>

#5

Dave Cohen - November 12, 2009 - 19:34
Status:needs review» fixed

I checked in a fix to fb_friends.module to support canvas pages and connect pages.

I'm trying now to make the Drupal for Facebook doc pages the best they can be. So instead of answering here, I wrote this: http://drupal.org/node/631216

If you run into problems with those instructions, use this issue queue for support.

#6

ahansen1 - November 13, 2009 - 12:18

With the noted patch I was once again able to use the invite form on D6. How I was able to accomplish similar functionality to the D5 fb/invite was to add the "Invite Facebook friends to install the current app" to a panel. This ended up working out well b/c then I was able to take over the whole page so that the full sized friend selector could be seen. The result can be seen here:

http://apps.facebook.com/howigotengaged/invite

It should be noted that as far as I can tell, the form alter given will only work on fb connect pages.

#7

Dave Cohen - November 13, 2009 - 18:52

It should be that the alter hooks are called whether in a canvas or connect page.

However, on a connect page, the default "wrap" will be the server-fbml tag. On canvas pages, it be an empty wrap.

And the example code I show, making the popup, is Facebook Connect only. I'm sure there's a way to accomplish that on canvas pages, but it would be using FBJS. The markup of my hook relies on some javascript in fb_connect.js to work. In short, I don't consider it a bug that the markup of that hook does not work on canvas pages. Its just an example of one way to use the hook.

#8

System Message - November 27, 2009 - 19:00
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.