getting onlinestatus to display on newly customized profiles page

whatistocome - July 13, 2006 - 14:54

i've been customizing the user profile pages by creating a user_profile.tpl.php and hooking to it from theme.php. i've used this section of the handbook for inspriation:

http://drupal.org/node/35728

i'm now trying to display the online status of users for chat programs (aim, msn, etc.) via the onlinestatus module.

i'm stuck on how to get the status displayed on the new profile pages.

i'm calling this within the user_profile.tpl.php and it doesn't display anything:

<?php
theme_onlinestatus_profile
($user)
?>

but when i revert to the original profile page layout, it displays the online status's just fine (that tells me everything is set up correctly regarding the installation and configuration of the onlinestatus module itself).

this is my first time trying to call upon module/theme functions, so i just might be missing the basics of how to do this in general.

any and all help is much appreicated. when i get this working, i'll definitely contribute the code to the handbook page above.

(i put this thread in module development, thinking that more code-centric folk will read it, but let me know if it might get a better response elsewhere)

- Jason

i'm booking marking this as

stanbroughl - July 13, 2006 - 15:20

i'm booking marking this as i want to know how to do this as well - i'm only 4 weeks into drupal and php so my php scripting is not quite there to work out how to do this yet!

i figured some of it out...

whatistocome - July 14, 2006 - 18:05

to call a theme function named theme_onlinestatus_profile($user), you actually call it with this syntax:

print theme(onlinestatus_profile, $user)

i put that into my new profile template and it doesn't work :) but...

print theme(onlinestatus_indicator, $user, $messenger) works, where $messenger is the name of one of the supported chat progs (aim, msn, etc)

i'm not sure why theme_onlinestatus_profile isn't working, so what i did was copy most of its code from onlinestatus.module and put it right into my new profile name, and it's working great:

<?php

$items
= array();
foreach (
onlinestatus_get_messengers(true) as $messenger => $title)
{
if (empty (
$user->$messenger))
{
  continue;
}
$status = onlinestatus_messenger('status', $messenger, $user);
$image = theme('onlinestatus_indicator', $user, $messenger);
$url = onlinestatus_messenger('url', $messenger, $user);
$items[] = array('value' => sprintf('%s  <a href="%s">%s (%s)</a>', $image, $url, $user->$messenger, $status),);
}

foreach (
$items as $term)
{
print(
$term['value']) . "<br>";
}
?>

 
 

Drupal is a registered trademark of Dries Buytaert.