1
andersa
Getting a blank page when developing new module
  • 2004/7/13 13:19

  • andersa

  • Just popping in

  • Posts: 45

  • Since: 2004/5/27


I use this code in the index.php file of my module.

Quote:
require('header.php');

// Find out it current user is a member of the group active users or if it's a guest user
if($xoopsUser->isGuest())
{
$isguest = True;
}
else
{
$isguest = False;
$ugroups = $xoopsUser->getGroups();
if(in_array(4,$ugroups)) $uactive = True;
else $uactive = False;
}

// Get list to fill out table
$member_handler =& xoops_gethandler('member');
$activeusers = $member_handler->getUsersByGroup(4,true,getUserCountByGroup(4),0);
$inactiveusers = $member_handler->getUsersByGroup(5,true,getUserCountByGroup(5),0);

// Generate table

$colmember = 'Medlem';
$colrank = 'Post';
$colemail = 'Email';
$outtable = '';

foreach($activeusers as $user)
{
$outtable .= '';
$outtable .= ''.$user->name().'';
$outtable .= ''.$user->rank().'';
if($isguest)
{
$outtable .= ''.$user->email().'';
}
else
{
$outtable .= ''.$user->email().'';
}
$outtable .= '';
}

foreach($inactiveusers as $user)
{
$outtable .= '';
$outtable .= ''.$user->name().'';
$outtable .= ''.$user->rank().'';
if($isguest)
{
$outtable .= ''.$user->email().'';
}
else
{
$outtable .= ''.$user->email().'';
};
$outtable .= '';
}

// We must always set our main template before including the header
$xoopsOption['template_main'] = 'memberlist_list.html';

// Include the page header
require(XOOPS_ROOT_PATH.'/header.php');

$xoopsTpl->assign('member', $colmember);
$xoopsTpl->assign('rank', $colrank);
$xoopsTpl->assign('email', $colemail);
$xoopsTpl->assign('memberlist', $outtable);

// Include the page footer
require(XOOPS_ROOT_PATH.'/footer.php');
?>


And this is the template:

Quote:


<{$member}>
<{$rank}>
<{$email}>

<{$memberlist}>


All I get is a completely empty page, not even any html header tags or anything. Can anyone spot any obvious mistakes?

2
Mithrandir
Re: Getting a blank page when developing new module

First off always put on php debug, when changing code

Secondly, instead of this:
// Find out it current user is a member of the group active users or if it's a guest user
if($xoopsUser->isGuest())
{
$isguest True;
}
else
{
$isguest False;
$ugroups $xoopsUser->getGroups();
if(
in_array(4,$ugroups)) $uactive True;
else 
$uactive False;
}


use this:
// Find out it current user is a member of the group active users or if it's a guest user
if(!$xoopsUser//$xoopsUser object is empty if visitor is not a user
{
     
$isguest True;
}
else
{
     
$isguest False;
     
$ugroups $xoopsUser->getGroups();
     if(
in_array(4,$ugroups)) $uactive True;
     else 
$uactive False;
}


You most likely have a "Call to a member function on a non-object" by calling a method on the $xoopsUser object, which is null for anonymous users.

3
andersa
Re: Getting a blank page when developing new module
  • 2004/7/13 13:43

  • andersa

  • Just popping in

  • Posts: 45

  • Since: 2004/5/27


Great tips! Thanks. It was the getUsercountbyGroup() call that should have been associated with the member_handler object.

4
Mithrandir
Re: Getting a blank page when developing new module

right - but isn't that call rather superflous? Instead of one SQL query, you have two. If the limit is set to 0 it should fetch all records.

Also the original code (with the fixed getUserCount... calls) will still produce a blank page for anonymous users, I believe due to what I wrote earlier.

Login

Who's Online

264 user(s) are online (137 user(s) are browsing Support Forums)


Members: 0


Guests: 264


more...

Donat-O-Meter

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

Latest GitHub Commits