Hi, I'm using your module and I want to add the user's picture next to the list item. It would be easy for me to do this if the list items were rendered via a theme function which they currently are not. Here are the changes I made for this to be the case. Could you include them in your next release ? Thanks !
Add
/**
* Implementation of hook_theme().
*/
function facebook_status_theme() {
return array(
'facebook_status_item' => array(
'arguments' => array(
'user_for_status' => NULL,
'status_long' => NULL,
'status' => NULL,
'time' => NULL
),
),
);
}
function theme_facebook_status_item($user_for_status,$status_long,$status,$time) {
return t("<span class='fbs_list_item' title='@username @status_long'> !user @status_short <div class='submitted'>!time ago</div></span>", array('@username' => $user_for_status->name, '@status_long' => $status_long, '!user' => theme('username', $user_for_status), '@status_short' => $status, '!time' => $time, 1));
}
Change line 1022 (end of facebook_status_list_render function) to
$list[] = theme('facebook_status_item',$user2, $row['status_fb'], $status,$time);
Thanks to these changes, I can add this to my template.php file to get the account picture:
function phptemplate_facebook_status_item($user_for_status,$status_long,$status,$time) {
return theme('user_picture',$user_for_status).t(" !user @status_short
", array('@username' => $user_for_status->name, '@status_long' => $status_long, '!user' => theme('username', $user_for_status), '@status_short' => $status, '!time' => $time, 1));
}
Comments
Comment #1
icecreamyou commentedSounds reasonable.
Comment #2
icecreamyou commentedI'd like to get equivalent code for the 5.x branch before I commit this to 6.x. Anyone care to write it?
Comment #3
icecreamyou commentedActually, this should work for 5.x too, without facebook_status_theme(), right? I'll try to get this in my local copy sometime today--and I think this is the last issue I need to resolve before releasing a beta!
Comment #4
icecreamyou commentedSo... this is the last issue holding up a beta release, and I'd really like to get this resolved; but the code isn't working for me in 6.x. I tried using the exact code posted by PGiro, as well as this code:
The second function is all that's needed for 5.x to work.
Any ideas?
Comment #5
PGiro commentedWhat is the problem ?
Comment #6
icecreamyou commentedNothing shows up with anything called like this:
But there are no errors logged, and this works fine:
So any blocks using facebook_status_list_render() display nothing.
Comment #7
PGiro commentedDid you clear your caches to force the theme registry to reload ?
I'm not a drupal expert but I don't think what you're doing in hook_theme() works. That method is not to actually theme anything, it's a hook to define all the functions in your code that can be called for theming.
Comment #8
icecreamyou commentedSure enough, that was it. Thanks. I'm about to commit all the changes from this week!