We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29181
    • 480 Posts
    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 smiley

    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
      Adrian Lawley: www.adrianlawley.com
      • 26435
      • 1,193 Posts
      Damn Taff!
      You da’ man!

      I have been dreading looking into pagination, but I knew it would be inevitable. Thanks for another contribution. You are one step closer to becoming a master of the Fine Pirate Arts.

      -sD-
      Dr. Scotty Delicious, DFPA.
        Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
        All of the above... in no specific order.


        I send pointless little messages
        • 29181
        • 480 Posts
        Quote from: Dr. at Dec 05, 2007, 06:48 AM


        You are one step closer to becoming a master of the Fine Pirate Arts.


        That would be like Christmas, Easter and Birthday all rolled into one...better than Action Man with Eagle eyes and gripping eyes.

        It still needs a little tweaking, I wanted to add a one page forward and one page back link, but once that is done, I’ll zip it all up and you can take a look, just in case you fancy adding it to a future release.

        Although as I said, it’s nothing really special...at least not compared to what you have put together.

        Taff

        Taff
          Adrian Lawley: www.adrianlawley.com
          • 36571
          • 145 Posts
          This looks like an awsome addition.

          Have just installed it, and seems to be working OK. Will play with it a little more and report back with any problems.

          Great work gents.
            • 29181
            • 480 Posts
            Glad it worked for you.

            I have made a few improvements (ie a total number of pages to display with arrows, basically copying Google functionality) as we had over 165 pages...and growing by 2 members a day currently.

            I’ll speak to the client and see if he minds me offering it back to the community. After all, he paid for it, so it’s not mine to give away.

            I’m also working on a search for user function with Pikachu’s help...and alphabetical pagination too...

            Taff
              Adrian Lawley: www.adrianlawley.com
              • 36571
              • 145 Posts
              Hey Taff,

              Is there any more word on this? Is the client OK about you sharing this with the community?

              Also, are there any plans to allow one to edit the look of the page numbers with CSS classes, or is it simply a case of modifying the $output variable to add a css wrapper?

              Thanks for your help.
                • 29181
                • 480 Posts
                hey Daniel,
                still no word I’m afraid. I have to speak to them this week. I managed to twist my back, so work on a whole has been reduced to what I haven’t been able to talk clients out of or put off for a couple of weeks.

                I’ve done some more work on the pagination actually, and added a search for users function. The search itself would need some tweaking on a individual basis (I have 3 fields, first_name, last_name and maiden_name ) for this particular project as it is a university alumni project where peoples nmes may well have changed.

                If he gives the go ahead, I will add some comments. The new version does in fact have css classes applied to it.

                If you fancy, I could give you access to the restriced area (via a PM) for a bit so you can see how it looks, and whether it suits your needs.

                Taff
                  Adrian Lawley: www.adrianlawley.com
                  • 36571
                  • 145 Posts
                  It would be great if you could PM me the details. Cheers.
                    • 36571
                    • 145 Posts
                    That’s brilliant! Thanks Taff.

                    I think it will be very suitable for my initial requirements.

                    Also, is there a way to wrap some more CSS into it? For example a ’here’ class? Obviously nothing massively important. Just thinking out loud.

                    Keep me posted on whether the client is OK about sharing.

                    I have also build a VERY dirty search solution (still in alpha) which can be seen at http://casalink.digitalime.com/search.html. I would appreciate any feedback or suggestions.
                      • 29181
                      • 480 Posts
                      Your search seems to work just fine. I presume you are searching through various template variables, or is that a custom build with a table that contains data for all those properties?

                      As to adding some more CSS, I’m sure that wouldn’t be a problem, currently I wrapped everything into a PaginationPE div, have an extra class for each of the arrows (back one more than visible, back to 1, jump to end, jump to one more than visible).

                      Unfortuntely the client doesn’t appear to be too happy about me offering an updated script as Open Source. I’ll keep on it, and let you know how things progress.


                      Taff
                        Adrian Lawley: www.adrianlawley.com