Hi,

I have a custom user_profile.tpl.php profile template, and before I found this module for statuses I had simply created a custom profile field called "status." The reason why I chose to switch to use this was because I really liked the options of the slide down form, time of status submission, and recent submissions feed options.

The only problem is, I can't figure out how to print the specific status to the specific user profile on whom it belongs to. For example, If I was user "Jon Girard" on my profile page I would see my status, and also be able to update it. If I navigated to user "Addie Black's" profile, I could see her status, but not be able to update it (unless I was an administrator.)

I tried doing something like:

<?php
global $user;
$block = module_invoke('facebook_status', 'block', 'view', 2, $account->uid);
print $block['content'];
?>

but obviously that's not effective to what I'd like to do..

Any help please?

Jon.

Comments

icecreamyou’s picture

Status: Active » Closed (duplicate)

At the moment that I'm writing this, there's not a great way to do that. In the next -dev it will be easy, though, and the next -dev should be released today.

If you need this sooner than that, take a look at the facebook_status_block function.

Marking as duplicate of #327907 because it's essentially asking for the same thing.

JonGirard-1’s picture

Awesome, if it's released today that would be perfect (5x).

If not, I'll look into the facebook_status_block function.. would it be something like this?

$global user;
if ($account->uid==$user->uid) {
 return arg(0) == 'user' && arg(1) == $user->uid && !arg(2);         
}
else {
 return arg(0) == 'user' && is_numeric(arg(1)) && !arg(2);
}

Thanks for your help,

Jon.

icecreamyou’s picture

That's not how it works... hook_block is a special structure that Drupal looks at to figure out which blocks are available. You can't actually call it. I meant that you should look at the code in that function to try to adapt it as you need.

It looks like I'm not going to get this in today, as other things came up that I had to deal with... but hopefully it'll get in by tomorrow.

JonGirard-1’s picture

ok, I'll check back for it again tomorrow.. thanks for your help.

JonGirard-1’s picture

Very nice work on babelup.com.. I noticed you seem to have the status on different profiles perfected quite nicely on that site.. Any news on the module update?

icecreamyou’s picture

I committed the changes at what I thought was 23:55 yesterday (-dev releases get rebuilt every 12 hours) but due to the time change I was off by an hour. So a new release should have been generated 13 minutes ago. As noted in #327907, you can use this code to get what you want:

print facebook_status_display_form(arg(1)); //arg(1) should be the UID of the user whose profile is being viewed

Thanks for the compliment by the way... :)

JonGirard-1’s picture

Great.. thanks :)

The only problem is now even for standard authenticated users, they can go around to someone else's profile and click to see the status change box (EX: If I login as "Sid Meier" (a standard user) , and go to "Addie Black's profile" I can click on her status, the status change box drops down (but when I type something in, it changes my status, not hers.. so that's alright.)

I'll just fix that by adding some user tags

<?php
global $user;
if ($user->uid== $account->uid) {
print facebook_status_display_form(arg(1)); 

Now, I guess to get rid of the form being able to show up on everyone's profile I'd use (as described in the readme.txt)

facebook_status_get_status($fbs_uid, $num_results)

The only problem is, I've been playing for hours with that line of code, and I can only ever get it to say "array." I've substituted in numbers, added "arg," tried many things. What would be the right combo?

icecreamyou’s picture

You should not be having that first problem. I think I've identified why it's happening and I'm working on fixing it.

facebook_status_get_status returns an array of arrays. You could have discovered this by using this code:

<pre>
<?php print_r(facebook_status_get_status()); ?>
</pre>

The structure looks like this:

Array
(
    [0] => Array
        (
            [status_fb] => says hello.
            [status_time] => 1225862944
            [fbs_uid] => 1
        )

)

So to get your status, you need $variable[0]['status_fb'] where you assigned the result of facebook_status_get_status to $variable. Remember to use check_plain() and such before displaying it. Use format_interval(time() - $variable[0]['status_time'], 1) to display the posted-time in the same format as the rest of the module.

In general, if you're confused about something, it helps to look at the actual code.

icecreamyou’s picture

Assigned: Unassigned » icecreamyou

Fixed in -dev to be released in half an hour.

JonGirard-1’s picture

Awesome.. everything works perfectly now.. thanks so much again for ALL your help.

P.S.. I'm "jonnyg" on babbleup.. I'm starting to use it quite frequently now as I've grown quite fond of the McCain/ Obama discussions, and it's social network layout, functionality, and design is superb compared to all the others out there.. Heck, I think it's even better than the "new" facebook now.. haha

Thanks again,

Jon.

icecreamyou’s picture

Hahaha, thanks very much. That was my goal in designing the site, although the "New" Facebook uses a ton of AJAX and BabelUp has next to none. :-P