xoops forums

mjoel

Quite a regular
Posted on: 2008/12/24 2:54
mjoel
mjoel (Show more)
Quite a regular
Posts: 272
Since: 2006/12/9
#11

Re: Poster's status

i also tried this using the profile module in XOOPS 2.3...can someone correct this code?..i am always displayed as offline
Resized Image

1. open modules/profile/userinfo.php

find
//User info
$xoopsTpl->assign('uname'$thisUser->getVar('uname'));
$xoopsTpl->assign('email'$email);
$xoopsTpl->assign('avatar'$avatar);
$xoopsTpl->assign('recent_activity'_PROFILE_MA_RECENTACTIVITY);
$xoBreadcrumbs[] = array('title' => _PROFILE_MA_USERINFO);
include 
'footer.php';
?>



add this before the code above


$user_online = new XoopsUser($thisUser->getVar('uid'));
if (
$user_online->isOnline())
{
    
$xoopsTpl->assign('user_online'true);
}



Save and close


2. open modules/profiles/templates/profile_userinfo.html

find
<{foreach item=category from=$categories}>
    <{if isset(
$category.fields)}>
        <
div class="profile-list-category" id="profile-category-<{$category.cat_id}>">
            <
table class="outer" cellpadding="4" cellspacing="1">
                <
tr>
                  <
th colspan="2" align="center"><{$category.cat_title}></th>
                </
tr>
                <{foreach 
item=field from=$category.fields}>
                    <
tr>
                        <
td class="head"><{$field.title}></td>
                        <
td class="even"><{$field.value}></td>
                    </
tr>
                <{/foreach}>
            </
table>
        </
div>
    <{/if}>
<{/foreach}>

add this code before the code above

<br /><bOnline Status:</b> <{if $user_online == true}>
                <
span style='color:#ee0000;'>Online</span><br />
<{else}>
                <
span style='color:#000000;'>Offline</span><br />
<{/if}>



save & close.

clear cache (eg:xoops_data\caches\smarty_compile) (except for index.html)

Monika

Not too shy to talk
Posted on: 2008/12/24 3:04
Monika
Monika (Show more)
Not too shy to talk
Posts: 103
Since: 2008/12/19
#12

Re: Poster's status

Quote:
i tried this in yogurt 3.3rc2 with XOOPS 2.3
but it is not working..i am always showed as offline


me too the same problem always offline.

mjoel

Quite a regular
Posted on: 2008/12/24 3:10
mjoel
mjoel (Show more)
Quite a regular
Posts: 272
Since: 2006/12/9
#13

Re: Poster's status

i think there is something wrong with this code..need to modify it to work with XOOPS 2.3
//user online status

$user_online = new XoopsUser($thisUser->getVar('uid'));

if (
$user_online->isOnline())

{

    
$xoopsTpl->assign('user_online'true);

}

this is perfectly working in XOOPS 2.018 and the old version yogurt but not working anymore in XOOPS 2.3

iHackCode

Module Developer
Posted on: 2008/12/24 5:04
iHackCode
iHackCode (Show more)
Module Developer
Posts: 1036
Since: 2004/6/29
#14

Re: Poster's status

for the profile module it should say.(in modules/profile/userinfo.php)

if ($thisUser->isOnline())
{
    
$xoopsTpl->assign('user_online'true);
}


even though it does the same thing as the code you have. odd that it is not working for you.
CBB / LatestNews / Publisher / XM-Spotlight

(ノ◕ヮ◕)ノ*:・゚✧

mjoel

Quite a regular
Posted on: 2008/12/24 5:29
mjoel
mjoel (Show more)
Quite a regular
Posts: 272
Since: 2006/12/9
#15

Re: Poster's status

banditx i replaced my code with yours but no effect ..still i am displayed as offline


ghia

Community Support Member
Posted on: 2008/12/24 10:27
ghia
ghia (Show more)
Community Support Member
Posts: 4954
Since: 2008/7/3 1
#16

Re: Poster's status

Don't you have to encode the false case?
As with:
if ($thisUser->isOnline())
{
    
$xoopsTpl->assign('user_online'true);
}
else
{
    
$xoopsTpl->assign('user_online'false);
}

or:
$xoopsTpl->assign('user_online'$thisUser->isOnline());

Check in your template what $user_online is returning, by displaying it directly. If necessary adapt the
<{if $user_online == true}>

mjoel

Quite a regular
Posted on: 2008/12/24 14:10
mjoel
mjoel (Show more)
Quite a regular
Posts: 272
Since: 2006/12/9
#17

Re: Poster's status

Quote:

ghia wrote:
Don't you have to encode the false case?
As with:
if ($thisUser->isOnline())
{
    
$xoopsTpl->assign('user_online'true);
}
else
{
    
$xoopsTpl->assign('user_online'false);
}

or:
$xoopsTpl->assign('user_online'$thisUser->isOnline());



i tried replacing my code with yours but no effect..i am still displayed as offline even though i am logged in (online) !!
Quote:

Check in your template what $user_online is returning, by displaying it directly. If necessary adapt the
<{if $user_online == true}>

how do i do this ? i'm not a coder..i just follow examples..is it something like this
<br /><bOnline Status:</b> <{if $user_online == true}>
                <
span style='color:#ee0000;'>Online</span><br />
<{
$user_online}>
<{else}>
                <
span style='color:#000000;'>Offline</span><br />

<{
$user_online}>
<{/if}>


nothing is displayed just the word Online Status: Offline

trabis

Core Developer
Posted on: 2008/12/24 16:52
trabis
trabis (Show more)
Core Developer
Posts: 2268
Since: 2006/9/1 1
#18

Re: Poster's status

You must use the who's online block in order to have online members info.

However if you do not want to use the block, you can always edit header.php and paste this just above the closing '?>' tag:

$online_handler =& xoops_gethandler('online');
    
mt_srand((double)microtime()*1000000);
    
// set gc probabillity to 10% for now..
    
if (mt_rand(1100) < 11) {
        
$online_handler->gc(300);
    }
    if (
is_object($xoopsUser)) {
        
$uid $xoopsUser->getVar('uid');
        
$uname $xoopsUser->getVar('uname');
    } else {
        
$uid 0;
        
$uname '';
    }
    if (
is_object($xoopsModule)) {
        
$online_handler->write($uid$unametime(), $xoopsModule->getVar('mid'), $_SERVER['REMOTE_ADDR']);
    } else {
        
$online_handler->write($uid$unametime(), 0$_SERVER['REMOTE_ADDR']);
    }

trabis

Core Developer
Posted on: 2008/12/24 17:10
trabis
trabis (Show more)
Core Developer
Posts: 2268
Since: 2006/9/1 1
#19

Re: Poster's status

Or instead of using all that code you can also use:

include_once XOOPS_ROOT_PATH.'/modules/system/blocks/system_blocks.php';
b_system_online_show();


iHackCode

Module Developer
Posted on: 2008/12/24 17:53
iHackCode
iHackCode (Show more)
Module Developer
Posts: 1036
Since: 2004/6/29
#20

Re: Poster's status

aha i see trabis. now that makes sense.
CBB / LatestNews / Publisher / XM-Spotlight

(ノ◕ヮ◕)ノ*:・゚✧