How to display entire user list on members page w/NO pagination?

Permalink
I'm trying to display an entire user list without pagination on members page. The current pagination shows 10 users at a time.

I don't see any reference to pagination in either the controller or single page for the members.php page.

Anyone point me in the right direction?

invision
View Replies: View Best Answer
LucasAnderson replied on at Permalink Best Answer Reply
LucasAnderson
/concrete/models/user_list.php

Line 24

protected $itemsPerPage = 10;

You'll want to override this file, not just edit it completely.
invision replied on at Permalink Reply
invision
Lucas,

Thanks for the direction. Very helpful.

Here's how I accomplished what Lucas suggested (for those of you unclear on how to avoid modifying the core):

1) I searched for '/concrete/models/user_list.php' and copied the file to '/models/user_list.php'
2) Opened the copied file in a text editor and changed line 24:
protected $itemsPerPage = 10;


to
protected $itemsPerPage = 100;


This sets the new default to 100 records displayed, fine for my current project.

Curiously, when I remark that line out of the file, I get 20 users per page. Is there another place this is set?

Thanks for the tip, Lucas. I've marked your answer.

Sherm Stevens
http://www.invision-studios.com
LucasAnderson replied on at Permalink Reply
LucasAnderson
I believe the default is set in concrete/config/base.php

Line 373

define('SEARCH_CHUNK_SIZE','20');
invision replied on at Permalink Reply
invision
Awesome.

Where do you go to learn this stuff (other than experience)??!!

Sherm Stevens
http://www.invision-studios.com
Mnkras replied on at Permalink Reply
Mnkras
#1 asking me ;)
#2 going through the code
#3 search the code :)
LucasAnderson replied on at Permalink Reply
LucasAnderson
Mnkras is mostly wrong, as usual. Contrary to his own belief, he does not have the answer to everything.

Mainly I've learned it from experience. It has been necessary to touch almost every piece of the code in my years with this system. Also, it helps that each file usually points you in the right direction. You'll notice your controller for your members single page has a call to load a model called 'user_list'. I just looked in the models folder for the user_list.php file.

Also, I would suggest browsing the config files. There's some good stuff in there.
invision replied on at Permalink Reply
invision
The more I learn about C5, the more impressed I am. I've built basic CMSs from the ground up, and I would have NEVER thought of some of this stuff.

Thanks again for the help.
invision replied on at Permalink Reply
invision
"years" with this system? Are you on the core team or did you just get an early start?

I've been using C5 for less than a year. Clearly the best CMS product out there, especially from the end-user perspective.

I might add, sites are so easy to build & configure (especially with the add-on marketplace) that my business has increased exponentially. Everything is so much more stable than drupal or joomla plugins because of the structure in place.
LucasAnderson replied on at Permalink Reply
LucasAnderson
No, I'm not on the core team. I was just around right about the time they opened this up and started the community, so I've been through many versions.

As Shotster reminded me, I don't necessarily know everything or even the best way to do things, but I've been around for a long time and have great respect for the core team and concrete5.

The feeling about concrete5 is mutual. :)
Shotster replied on at Permalink Reply
Shotster
A much better approach that has no chance of breaking with core upgrades is to simply call the setItemsPerPage() public method.

$myUserList->setItemsPerPage( 100 );

-Steve
LucasAnderson replied on at Permalink Reply
LucasAnderson
I hardly think you could say that it has no chance of breaking with an upgrade, or is a much better approach, but you are correct, it is another approach.
Shotster replied on at Permalink Reply
Shotster
> I hardly think you could say that it has no chance
> of breaking with an upgrade,

Ok, it has VERY LITTLE chance of breaking with upgrades.

> or is a much better approach, but you are correct,
> it is another approach.

No, it is in fact WAY better (and simpler) than duplicating and overriding a core file and altering a protected property. I mean, it's precisely what that public method is for. Consider, for instance, what happens when the OP has another user list which he DOES want paginated. At some point, he'll have to invoke the method! Why not write a simple line of code from the outset instead of altering core files and altering private members? It's just not necessary.

-Steve
invision replied on at Permalink Reply
invision
I actually did that before Lucas' suggestion. Both work equally well. I was just trying to learn the source of the setting for future reference.

If you use the override folders, there's no chance upgrades to the core will overwrite your mods. Granted, you may have to adjust your override code, but I think it's pretty safe.

Sherm Stevens
http://www.invision-studios.com
Shotster replied on at Permalink Reply
Shotster
> If you use the override folders, there's no chance
> upgrades to the core will overwrite your mods.

Understood. What I'm saying is that the internal workings of the class itself could change in a new version of C5, and that could very well break parts of your site that rely on your customized implementation. You have to REMEMBER to check (and alter if necessary) your core overrides with each and every upgrade. Why do that when the problem is solved with one line of code?

> Granted, you may have to adjust your override code

Or more specifically, you have to REMEMBER to adjust your code. I've been bitten in the @ss more than once by that.

-Steve
makeway replied on at Permalink Reply
makeway
Couldn't you also just make a copy of user_list.php and stick it in the root "models" dir? This worked fine for me when I changed the value for $itemsPerPage
Shotster replied on at Permalink Reply
Shotster
> Couldn't you also just make a copy of user_list.php and stick it
> in the root "models" dir?

Yes, if you read the thread, you'll see that was suggested; but it has disadvantages.

-Steve
Shotster replied on at Permalink Reply
Shotster
> I'm trying to display an entire user list without pagination on members page.

You might find this recently released add-on helpful...

http://www.concrete5.org/marketplace/addons/enhanced-user-list/...

Among other things, pagination can be explicitly disabled (although it's disabled automatically if the number of users is less than the specified page size).

-Steve