Ticket #14 (new enhancement)

Opened 2 years ago

Last modified 4 months ago

Allow a variable number of items per page

Reported by: yoavf Owned by:
Priority: normal Milestone: Future Release
Component: interface Version:
Keywords: has-patch, needs-review Cc: joostdevalk

Description (last modified by nbachiyski) (diff)

GlotPress should let the user decide how many items to display per page.

For example: 5-20-50-100 etc...

Attachments

glotpress-profile.patch Download (2.9 KB) - added by joostdevalk 4 months ago.
glotpress-profile.2.patch Download (5.2 KB) - added by joostdevalk 4 months ago.
Version 2, using user_meta
glotpress-profile-2.patch Download (9.6 KB) - added by joostdevalk 4 months ago.
version 3, adding in sort options
glotpress-profile-3.patch Download (10.1 KB) - added by joostdevalk 4 months ago.
Patch #3 :)
glotpress-profile-3.2.patch Download (10.2 KB) - added by joostdevalk 4 months ago.
Patch #4

Change History

  • Description modified (diff)
  • Priority changed from major to normal
  • Milestone set to Future Release

I came up with a patch for this today as the default 15 annoyed the heck out of me and a lot of people. Attached patch adds a /profile page where people can set how many items they want displayed on a page, currently stored in a cookie.

Biggest issue I have with the patch myself is that it's stored in a cookie. In WP core I'd use a user_meta, I didn't see an API for that in GP yet (even though there is a gp_usermeta table), but I think that'd be the way to go. If we had that we could also store a default sort.

Last edited 4 months ago by joostdevalk (previous) (diff)
  • Keywords has-patch, needs-review added

See  GP_User::get_meta() and its friends.

Version 2, using user_meta

Ok found that indeed, couple of issues that needed fixing to get this to work:

  • get_meta, set_meta and delete_meta all assumed $this->id was filled, when it wasn't in this case, so switched them over to first using the current method of GP_User.
  • gp_update_meta always returned false when $global wasn't set, which it isn't when called from GP_User, so I removed that check.
  • GP_Thing's sql_limit_for_paging method first correctly set its internal $per_page variable to then use $this->per_page for the query, fixed.
  • GP_Translation now checks whether there's user setting per_page and uses that value, otherwise it reverts to its default.
  • Cc joostdevalk added

version 3, adding in sort options

Just found a bug in pagination, tracking down, don't commit patch yet.

Patch #3 :)

Pagination issue found and fixed, actually fixed it by implementing the $per_page fix cleaner and earlier, before getting the translations.

Patch #4

This last patch adds a redirect for non-logged in users to the login page when they try to open the /profile page.

Note: See TracTickets for help on using tickets.