Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sane default pagination order baked by default #1021

Open
dereuromark opened this issue Nov 29, 2024 · 4 comments
Open

Sane default pagination order baked by default #1021

dereuromark opened this issue Nov 29, 2024 · 4 comments

Comments

@dereuromark
Copy link
Member

dereuromark commented Nov 29, 2024

Description

I had to do this a lot manually over the years
We should probably adapt this as a sane default of sorts:
dereuromark/cakephp-setup@f22cda0

The idea is that once there is a field like created, the pagination would sort DESC on this.
As it is usually not useful to scroll to the last page here to see the latest updates coming into this table.
I never had to NOT use this so far.

The generated code above the actions would be e.g.

class BanksController extends AppController
{
    /**
     * @var array<string, mixed>
     */
    protected array $paginate = [
        'order' => [
            'Banks.created' => 'DESC',
        ],
    ];
@ADmad
Copy link
Member

ADmad commented Nov 29, 2024

While having a good default order is nice always using the created column isn't. I add the created/modified column to almost all tables but there are cases where alphabetical sorting on the display field is preferred.

Also I handle the default ordering at the model level using the Orderly plugin.

@dereuromark
Copy link
Member Author

So you say we shouldnt bake this in by default?

@ADmad
Copy link
Member

ADmad commented Nov 29, 2024

No we shouldn't. It would be fine as an option for the controller command, for e.g. --paginate-order created.

@dereuromark
Copy link
Member Author

dereuromark commented Nov 29, 2024

That sounds like a useful addition via param or config :)
If anyone wants to add it, based on my work in my plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants