11
mjoel
Re: Poster's status
  • 2008/12/24 2:54

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


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
le="color: #000000"><?php //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


le="color: #000000"><?php $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
le="color: #000000"><?php <{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

le="color: #000000"><?php <br /><b> Online 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)


12
Monika
Re: Poster's status
  • 2008/12/24 3:04

  • Monika

  • Not too shy to talk

  • Posts: 103

  • Since: 2008/12/19


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.

13
mjoel
Re: Poster's status
  • 2008/12/24 3:10

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


i think there is something wrong with this code..need to modify it to work with XOOPS 2.3
le="color: #000000"><?php //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

14
iHackCode
Re: Poster's status

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

le="color: #000000"><?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

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

15
mjoel
Re: Poster's status
  • 2008/12/24 5:29

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


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



16
ghia
Re: Poster's status
  • 2008/12/24 10:27

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Don't you have to encode the false case?
As with:
le="color: #000000"><?php if ($thisUser->isOnline()) { $xoopsTpl->assign('user_online', true); } else { $xoopsTpl->assign('user_online', false); }

or:
le="color: #000000"><?php $xoopsTpl->assign('user_online', $thisUser->isOnline());

Check in your template what $user_online is returning, by displaying it directly. If necessary adapt the
le="color: #000000"><?php <{if $user_online == true}>

17
mjoel
Re: Poster's status
  • 2008/12/24 14:10

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


Quote:

ghia wrote:
Don't you have to encode the false case?
As with:
le="color: #000000"><?php if ($thisUser->isOnline()) { $xoopsTpl->assign('user_online', true); } else { $xoopsTpl->assign('user_online', false); }

or:
le="color: #000000"><?php $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
le="color: #000000"><?php <{if $user_online == true}>

how do i do this ? i'm not a coder..i just follow examples..is it something like this
le="color: #000000"><?php <br /><b> Online 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

18
trabis
Re: Poster's status
  • 2008/12/24 16:52

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


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:

le="color: #000000"><?php $online_handler =& xoops_gethandler('online'); mt_srand((double)microtime()*1000000); // set gc probabillity to 10% for now.. if (mt_rand(1, 100) < 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, $uname, time(), $xoopsModule->getVar('mid'), $_SERVER['REMOTE_ADDR']); } else { $online_handler->write($uid, $uname, time(), 0, $_SERVER['REMOTE_ADDR']); }

19
trabis
Re: Poster's status
  • 2008/12/24 17:10

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


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

le="color: #000000"><?php include_once XOOPS_ROOT_PATH.'/modules/system/blocks/system_blocks.php'; b_system_online_show();



20
iHackCode
Re: Poster's status

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

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

Who's Online

766 user(s) are online (721 user(s) are browsing Support Forums)


Members: 0


Guests: 766


more...

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits