We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18913
    • 654 Posts
    I’m using WebLoginPE to manage a large list of website members (e.g. 200-ish). For the admin/manager to deal with one long page of user entries when &type=`manage` isn’t going to work.

    Yet looking around, I don’t see any pagination solutions, except for a reference to pagination in the version 1.3.2 beta site at code.google.com

    Can anyone tell me if the 1.3.2 beta is a) fairly stable, b) that the pagination reference I saw would pertain to the web user list and c) any alternative means of pagination using the current version (1.3.1) of the snippet?

    EDIT : Okay, I finally found Taff’s contribution on pagination. Looks like my alternative is to use the info in that thread or use the 1.3.2Beta code ...

    Thanks in advance!
    MattC
      • 1169
      • 312 Posts
      To my knowlege taff’s code is in V1.3.1

      I am not sure if it works needs a parameter set as default is 3000 if I remember correct.
        DEVELOPMENT ENV:- Ubuntu 12.04 | MODx Revolution 2.2.8 | LAMP 2i Apache 2.2.22 | Php 5.3.10 | Mysql 5.5.31 MySQL client version: 5.5.31
        • 18913
        • 654 Posts
        Hi,
        Yup, Taff’s stuff is there. But it looks like there’s a problem on the sort order when "usersList" is used as a parameter. Seems like it might be the same problem noted at the end of this thread
        http://modxcms.com/forums/index.php?topic=20396.20
        but there doesn’t seem to be a workaround posted ...
        MattC
          • 18913
          • 654 Posts
          Okay, I’ve gotten the sorting issue figured out.

          Recap : what I wanted to do was sort the user list not by username but by another field, in this case fullname. But I didn’t want everything on one page either. The Taff code seems to sort things once they’re on a page, rather than sort and then divide everything up into pages.

          To fix this I needed to edit the function "ViewAllUsers". (Note : this is in the webloginpe.class.php code and the version I was working from was an early beta, not the current one)

          - adding the two lines here with my initials near the beginning of the function :
          		$web_users = $modx->getFullTableName('web_users');
          		$web_user_attributes = $modx->getFullTableName('web_user_attributes');  //MattC
          		$web_user_attributes_extended = $modx->getFullTableName('web_user_attributes_extended');  //MattC        
          		$allRows = $modx->db->query("SELECT id FROM ".$web_users);

          - commenting out these two lines with my initials a bit further down :
          		echo $output;
          		//$fetchUsers = $modx->db->query("SELECT `username` FROM ".$web_users."ORDER BY `username` LIMIT ".$positionInList.",".$pagination);//MattC
          
          		//$allUsers = $this->FetchAll($fetchUsers);//MattC
          		
          		if ($listUsers == '')

          - and moving them down further, adding an edit at the same time :
          				// Filters.
          				if ($format[5] == '')
          				{
          					$format[5] = 'username()';
          				}
          
          		$fetchUsers = $modx->db->query("SELECT `username` FROM ".$web_users." left join ".$web_user_attributes." ON ".$web_users.".`id`=".$web_user_attributes.".`internalKey` ORDER BY ".$web_user_attributes.".`".$listSortBy."` LIMIT ".$positionInList.",".$pagination);//MattC
          
          		$allUsers = $this->FetchAll($fetchUsers);//MattC
          				
          				$CompleteUserList = array();


          Two things to note. I added a variable to point to the "extended" table because we might want to sort on a field there. But that is not used in my edit above.

          Which brings up the second issue. As written, this now allows me to select based on username but sort based on fullname. (Username is in the web_users table while fullname is in the web_users_attributes table.) But that’s not very flexible.

          Seeing as I’m no whiz with SQL syntax, can someone suggest a general query formulation that would allow for the user list to be sorted on any field in the web_users, web_user_attributes and web_user_attributes_extended table? Or is there a better place to make the changes such that sorting-with-pagination works?

          Matt
            • 29487
            • 385 Posts
              • 18913
              • 654 Posts
              Hi,
              Thanks for that link. That pagination code produces nicer looking output and allows for some CSS styling. And I’m able to remove most of the changes I made as well as the existing pagination code. So that’s a good thing!

              Still, unless I am doing something wrong, sorting by a field in the "extended" table doesn’t work. And given that the "extended" table is set up by the snippet, one would hope we’d be able to use it smiley So I hope one way or the other someone can set me straight!
              Thanks again,
              MattC
                • 16501
                • 28 Posts
                Here’s my snippet call that sorts by a field in the extended table.
                [!WebLoginPE? &type=`manager` &manageTpl=`wlpeManageUsers` &manageProfileTpl=`wlpeEditProfile` &usersList=`Customer:default:default:firstname:ASC:webgroup(Customer)` &customFields=`firstname,lastname,address,town,postcode`!]