1
Robustus
How to customiseYogurt Block "yogurt_block_friends.html"?
  • 2008/12/13 8:48

  • Robustus

  • Just popping in

  • Posts: 30

  • Since: 2008/5/19


Hello all,
i would like to customise the Yogurt Block "yogurt_block_friends.html". It showing the friends of a User. But the Block is useless because the friends are already shown in Yogurt itself.

It would be perfect if the Block shows only the friends who are online. Title would be like "My friends Online".
I tried a lot without success.
Any help is welcome, thanks.

2
trabis
Re: How to customiseYogurt Block "yogurt_block_friends.html"?
  • 2008/12/13 12:53

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


I did not have time to test this but you can do something like this:
function b_yogurt_friends_show($options) {
    global 
$xoopsDB$xoopsModule$xoopsModuleConfig$xoopsUser;
    
$myts =& MyTextSanitizer::getInstance();
    
$block = array();
    
$friends = array();
    
$onlinehandler =& xoops_gethandler('online');
    
$uid = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0;
    
$onlines $onlinehandler->getAll();
    
$i 0;
    foreach(
$onlines as $online){
        if (
$online['online_uid'] != $uid) {
            
$thisUser = new XoopsUser($online['online_uid']);
            
$friends[$i]['uid'] = $thisUser->getVar('uid');
            
$friends[$i]['uname'] = $thisUser->getVar('uname');
            
$friends[$i]['user_avatar'] = $thisUser->getVar('user_avatar');
            
$i++;
        }
    }

    
$block['friends'] = $friends;
    
$block['lang_allfriends']=_MB_YOG_ALLFRIENDS;
    return 
$block;
}

3
Robustus
Re: How to customiseYogurt Block "yogurt_block_friends.html"?
  • 2008/12/13 20:52

  • Robustus

  • Just popping in

  • Posts: 30

  • Since: 2008/5/19


Thanks for your effort trabis, but it don`t work
The Blocks schows now every Onlinemember and also a Blank Pm Button (when clicking it will send to Guest).

4
trabis
Re: How to customiseYogurt Block "yogurt_block_friends.html"?
  • 2008/12/13 22:42

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

Robustus wrote:
The Blocks schows now every Onlinemember and also a Blank Pm Button (when clicking it will send to Guest).


Not Bad! Try this please:
function b_yogurt_friends_show($options) {
    global 
$xoopsDB$xoopsModule$xoopsModuleConfig$xoopsUser;
    
$myts =& MyTextSanitizer::getInstance();
    
$block = array();
    
$friends = array();
    
$onlinehandler =& xoops_gethandler('online');
    
$uid = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0;
    
$criteria = new CriteriaCompo(new Criteria('online_uid'0'>'));
    
$criteria->add(new Criteria('online_uid'$uid'<>');
    
$criteria->setOrder('rand()');
    
$criteria->setLimit($options[0]);
    
$onlines $onlinehandler->getAll($criteria);
    
$i 0;
    foreach(
$onlines as $online){
        
$thisUser = new XoopsUser($online['online_uid']);
        
$friends[$i]['uid'] = $thisUser->getVar('uid');
        
$friends[$i]['uname'] = $thisUser->getVar('uname');
        
$friends[$i]['user_avatar'] = $thisUser->getVar('user_avatar');
        
$i++;
    }

    
$block['friends'] = $friends;
    
$block['lang_allfriends']=_MB_YOG_ALLFRIENDS;
    return 
$block;
}

5
Robustus
Re: How to customiseYogurt Block "yogurt_block_friends.html"?
  • 2008/12/14 8:38

  • Robustus

  • Just popping in

  • Posts: 30

  • Since: 2008/5/19


This occurs now an Errormessage:
Parse error: syntax error, unexpected ';' in /modules/yogurt/blocks/blocks.php on line 42

42 is:
$criteria->add(new Criteria('online_uid'$uid'<>');

I have a Question for better understanding:
Is it not much easier to leave the blocks.php as it is and to modify the yogurt_block_friends.html like this way:

"if user is online"
<a href="<{$xoops_url}>/modules/yogurt/index.php?uid=<{$block.friends[i].uid}>"  title="<{$block.friends[i].uname}>"><{ if $block.friends[i].user_avatar=="blank.gif" }> <img src="<{$xoops_url}>/modules/yogurt/images/noavatar.gif" /> <{else}> <img src="<{$xoops_upload_url}>/<{$block.friends[i].user_avatar}>" /><{/if}><br /><{$block.friends[i].uname}> a>     <br /><a href='javascript:openWithSelfMain("<{$xoops_url}>/pmlite.php?send2=1&to_userid=<{$block.friends[i].uid}>","pmlite",500,450);'><img src="<{$xoops_url}>/images/icons/pm.gif" />a>     div><br /> <{/section}>

"else"
<a href="<{$xoops_url}>/modules/yogurt/friends.php"><{$block.lang_allfriends}>a>

Or wouldn`t work this way?

6
trabis
Re: How to customiseYogurt Block "yogurt_block_friends.html"?
  • 2008/12/14 12:02

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


It had a missing ')'

Ok ,sorry, I missunderstood your request.
This block is for showing users online and not friends online.

function b_yogurt_friends_show($options) {
    global 
$xoopsDB$xoopsModule$xoopsModuleConfig$xoopsUser;
    
$myts =& MyTextSanitizer::getInstance();
    
$block = array();
    
$friends = array();
    
$onlinehandler =& xoops_gethandler('online');
    
$uid = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0;
    
$criteria = new CriteriaCompo(new Criteria('online_uid'0'>'));
    
$criteria->add(new Criteria('online_uid'$uid'<>'));
    
$criteria->setOrder('rand()');
    
$criteria->setLimit($options[0]);
    
$onlines $onlinehandler->getAll($criteria);
    
$i 0;
    foreach(
$onlines as $online){
        
$thisUser = new XoopsUser($online['online_uid']);
        
$friends[$i]['uid'] = $thisUser->getVar('uid');
        
$friends[$i]['uname'] = $thisUser->getVar('uname');
        
$friends[$i]['user_avatar'] = $thisUser->getVar('user_avatar');
        
$i++;
    }

    
$block['friends'] = $friends;
    
$block['lang_allfriends']=_MB_YOG_ALLFRIENDS;
    return 
$block;
}

7
Robustus
Re: How to customiseYogurt Block "yogurt_block_friends.html"?
  • 2008/12/14 12:16

  • Robustus

  • Just popping in

  • Posts: 30

  • Since: 2008/5/19


Of course i will try as much as necessary. Thank you very much for your Support.

Same Error Occurs:
Parse errorsyntax errorunexpected ';' in /modules/yogurt/blocks/blocks.php on line 42

8
trabis
Re: How to customiseYogurt Block "yogurt_block_friends.html"?
  • 2008/12/14 12:33

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

Same Error Occurs:
Parse errorsyntax errorunexpected ';' in /modules/yogurt/blocks/blocks.php on line 42


I changed wrong line, I'm sleeping. Please try again?!

9
Robustus
Re: How to customiseYogurt Block "yogurt_block_friends.html"?
  • 2008/12/14 12:49

  • Robustus

  • Just popping in

  • Posts: 30

  • Since: 2008/5/19


Works fine now, but the Block shows every member who is online.
Maybe there is a way to restrict displaying only for Friends?

10
trabis
Re: How to customiseYogurt Block "yogurt_block_friends.html"?
  • 2008/12/14 13:18

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Try this one, lol
function b_yogurt_friends_show($options) {
    global 
$xoopsDB$xoopsModule$xoopsModuleConfig$xoopsUser;
    
$myts =& MyTextSanitizer::getInstance();
    
$block = array();
    
$online_uids = array();
    if (!empty(
$xoopsUser)){
        
$onlinehandler =& xoops_gethandler('online');
        
$onlines $onlinehandler->getAll();
        
$online_uids[0] = 0;
        foreach(
$onlines as $online){
            
$online_uids[$online['online_uid']] = $online['online_uid'];
        }
    
        
$friends_factory  = new Xoopsyogurt_friendshipHandler($xoopsDB);
        
$criteria  = new CriteriaCompo( new criteria('friend1_uid',$xoopsUser->getVar('uid')));
        
$criteria->add( new Criteria('friend2_uid','('.implode(','array_keys($online_uids)).')','IN')); 

        
$block['friends'] = $friends_factory->getFriends($options[0], $criteria1);
        
$block['lang_allfriends']=_MB_YOG_ALLFRIENDS;
    }

    return 
$block;
}


Not tested

Login

Who's Online

322 user(s) are online (237 user(s) are browsing Support Forums)


Members: 0


Guests: 322


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits