Has anyone had that many users that they have had to paginate in someway?
I have 1271 users and you can imagine how long that takes to list!
Cheers,
Taff
EDIT:
I manipulated the webloginpe class slightly to allow for pagination. It’s actually more of a nasty hack, but I was on a tight timeframe which is my excuse
Line 138 I added:
var $paging;
/**
* Number of items listed on one page
*
* @var number
*/
I changed the constructor (Line 153) slightly to now look like this:
function __construct($LanguageArray, $dateFormat = '%A %B %d, %Y at %I:%M %p', $UserImageSettings = '105000,100,100', $type = 'simple', $paging = 3000)
{
require_once 'manager/includes/controls/class.phpmailer.php';
$this->LanguageArray = $LanguageArray;
$this->DateFormat = $dateFormat;
$this->UserImageSettings = $UserImageSettings;
$this->Type = $type;
//Added by Taff
$this->Pagination = $paging;
}
For PHP 4 you will probably need to change line 169 too.
I made a couple of additions to the ViewAllUsers function so now it looks like this:
<?php
global $modx;
$positionInList =trim($_REQUEST['pag']);
if(!is_numeric($positionInList)){
$positionInList=0;
}
$numRows = "SELECT count(*) FROM ".$web_users;
$web_users = $modx->getFullTableName('web_users');
$allRows = $modx->db->query("SELECT id FROM ".$web_users);
$alumni = mysql_num_rows($allRows);
$num_rows = ceil($alumni/$this->Pagination);
for($i=1;$i<=$num_rows;$i++){
$startPos = $i*$this->Pagination-$this->Pagination;
if($startPos !=$positionInList){
$output.=" <a href=\"index.php?id=".$modx->documentIdentifier."&pag=".$startPos."\">".$i."</a>";
}
else{
$output.=" ".$i;
}
}
echo $output;
$fetchUsers = $modx->db->query("SELECT `username` FROM ".$web_users."LIMIT ".$positionInList.",".$this->Pagination);?>
in front of
$allUsers = $this->FetchAll($fetchUsers);
The snippet itself was slightly changed to allow for our new parameter:
$paging = isset($paging) ? $paging : 3000;
somewhere near the top.
and replace the $wlpe with:
$wlpe = new WebLoginPE($wlpe_lang, $dateFormat, $userImageSettings, $type, $paging);
If you now want pagination on a page add &paging=`15` to your snippet call.
Hope that helps someone else sometime.
Taff