Warning: Table './dff_live/watchdog' is marked as crashed and should be repaired query: INSERT INTO watchdog (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (0, 'php', '%message in %file on line %line.', 'a:4:{s:6:\"%error\";s:7:\"warning\";s:8:\"%message\";s:40:\"Creating default object from empty value\";s:5:\"%file\";s:63:\"/srv/drupalforfacebook.org/profiles/custom/modules/fb/fb.module\";s:5:\"%line\";i:1079;}', 3, '', 'http://www.drupalforfacebook.org/fb_cb/NNN/node/2155', '', '50.16.166.175', 1371725013) in /srv/drupalforfacebook.org/includes/database.mysqli.inc on line 134 Call Stack: 0.0002 129256 1. {main}() /srv/drupalforfacebook.org/index.php:0 0.2573 7200464 2. theme() /srv/drupalforfacebook.org/index.php:35 0.2574 7213348 3. call_user_func_array() /srv/drupalforfacebook.org/includes/theme.inc:709 0.2574 7213568 4. template_preprocess_page() /srv/drupalforfacebook.org/includes/theme.inc:709 0.2761 7358704 5. theme() /srv/drupalforfacebook.org/includes/theme.inc:1835 0.2762 7359024 6. call_user_func_array() /srv/drupalforfacebook.org/includes/theme.inc:668 0.2762 7359200 7. theme_blocks() /srv/drupalforfacebook.org/includes/theme.inc:668 0.2762 7359228 8. block_list() /srv/drupalforfacebook.org/includes/theme.inc:1641 0.2762 7359500 9. module_invoke() /srv/drupalforfacebook.org/modules/block/block.module:522 0.2762 7359952 10. call_user_func_array() /srv/drupalforfacebook.org/includes/module.inc:461 0.2762 7360172 11. fb_connect_block() /srv/drupalforfacebook.org/includes/module.inc:461 0.2789 7495900 12. drupal_alter() /srv/drupalforfacebook.org/profiles/custom/modules/fb/fb_connect.module:277 0.2792 7496756 13. call_user_func_array() /srv/drupalforfacebook.org/includes/common.inc:2907 0.2792 7496932 14. fb_permission_fb_required_perms_alter() /srv/drupalforfacebook.org/includes/common.inc:2907 0.2792 7496948 15. fb_get_app_data() /srv/drupalforfacebook.org/profiles/custom/modules/fb/contrib/fb_permission.module:47 0.2792 7497580 16. drupal_error_handler() /srv/drupalforfacebook.org/profiles/custom/modules/fb/contrib/fb_permission.module:1079 0.2793 7499212 17. watchdog() /srv/drupalforfacebook.org/includes/common.inc:665 0.2796 7500584 18. module_invoke() /srv/drupalforfacebook.org/includes/bootstrap.inc:965 0.2796 7501484 19. call_user_func_array() /srv/drupalforfacebook.org/includes/module.inc:461 0.2796 7501660 20. dblog_watchdog() /srv/drupalforfacebook.org/includes/module.inc:461 0.2796 7502008 21. db_query() /srv/drupalforfacebook.org/modules/dblog/dblog.module:146 0.2798 7504384 22. _db_query() /srv/drupalforfacebook.org/includes/database.mysql-common.inc:41 0.2801 7506004 23. trigger_error() /srv/drupalforfacebook.org/includes/database.mysqli.inc:134 howto: basic snippet to get a user's details into your tpl.php or template.php files |

howto: basic snippet to get a user's details into your tpl.php or template.php files

After installing Drupal for Facebook, it was easy enough to configure the module settings, but finding the relevant functions to do the simple things that i wanted took me a little longer as i couldn't find any documentation listing useful theming tools, or tutorials on the subject. Oh well, i hope this helps someone out there.

The module wasn't automatically pulling in profile pics the one place that i wanted them, alongside comments.

once i found the functions fb_get_object_fbu and fb_users_getInfo everything fell into place.

if you're curious, fb_get_object_fbu is on line 550 of fb.module and is described as:

"Convenience function to learn the fbu associated with a user, node or comment. Used in theming (X)FBML tags."

fb_users_getInfo is in the same file, on line 1004:

Helper function for facebook's users_getInfo API.

This function makes calls to users_getInfo more efficient, by caching
results in the session, so calls do not always require hitting Facebook's
servers.

@param $oids
Array of facebook object IDs. In this case they should each be a user id.

so, to do what i wanted, it was as simple as opening up comment.tpl.php and dropping this in where needed.

<?php
$fbu = fb_get_object_fbu( $comment );
if ( $fbu ) { $fbu_info = fb_users_getInfo( array( $fbu ) ); }
if( $fbu_info[0]['pic_square'] ) {
print '<img src="'. $fbu_info[0]['pic_square'] . '" />'; }
?>

"pic_square" being the mini profile pic provided by facebook.

I just want to say a huge thanks to the developers of this module for making it so easy for me to connect with fb!

Thanks, glad you shared

Thanks, glad you shared that.

However... It's not supposed to be that hard. The modules should, by default, change theme('user_picture'...) to do the right thing. For example on this site, I have not tweaked the theme as you describe, and you should see your profile pic next to your comments (unless you specifically upload another pic to your local account).

Same Issue

I am facing the same issue. I can see the bigger Facebook picture under Drupal user. But the smaller squire image is the Facebook default image (shadow image of a guy) same case in this site also....can you please help me to get the smaller facebook image next to the comments?

yeah, well it didn't for some

yeah, well it didn't for some reason, no harm done though.

I don't mind, i'm actually starting from scratch, without an existing user base, and I'm probably just going to roll with the info from facebook and not even let (force) users (to tediously) update their pics/signatures/profiles themselves.

i ended up rolling something closer to this as it fits better with the way things are written up in the zen theme:

<?php
$fbu = fb_get_object_fbu( $comment );
if( $fbu ) { $fbu_info = fb_users_getInfo( array( $fbu ) ); }
if( is_array($fbu_info) && is_array($fbu_info[0]) && $fbu_info[0]['pic_square'] ) : ?>
*img src="<?php echo $fbu_info[0]['pic_square']; ?>" /*
<?php else : ?>
*div class="spacer"**/div*
<?php endif; ?>

where i use the 'spacer' div to display a default profile pic, with a little css magic.

i'm a forum noob

kk, so i don't know how to format the text to stop the img tag on the last line of my code from getting stripped out.

it should be obvious what to do though, the variable $fbu_info[0]['pic_square'] contains the url to the image :)

This forum makes it way

This forum makes it way harder than it should be. I'll look into that. In the meantime, here's a closer approximation of your code.

$fbu = fb_get_object_fbu( $comment );
if ( $fbu ) {
$fbu_info = fb_users_getInfo( array( $fbu ) );
}
if( $fbu_info[0]['pic_square'] ) {
print '<img src="'. $fbu_info[0]['pic_square'] . '" />';
}