Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-05-23 09:25:32

philwareham
Core designer
From: Farnham, Surrey, UK
Registered: 2009-06-11
Posts: 3,169
Website

List number per page filters - default on install

Hi,

I’ve noticed that when doing a clean install, the buttons on list pages that indicate/highlight how many entries a user wants to view per page have none selected at all. Once a user selects one the selection is persistent.

So:

  1. What is the default setting? Infinite or one of the amounts shown?
  2. If one of the amounts shown, shouldn’t it be visually highlighted?

Offline

#2 2016-05-23 10:04:48

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,611
Website

Re: List number per page filters - default on install

philwareham wrote #299209:

What is the default setting? Infinite or one of the amounts shown?

In 4.5.x, the select list we used meant the first entry was automatically selected by the browser, even if that was not technically the default that was set in prefs. In reality, the pref is not set at all until the page is interacted with in some way, so it was kind of a false cue, but it worked because the core defaults to using the first item (15) in its pagination function (see nav_form()).

There’s an inelegant, yet functional fix we could apply in pageby_form() to do the trick now we’re not using a select list:

...
    if ($step === null) {
        $step = $event.'_change_pageby';
    }

    if (empty($val)) {
        $val = $vals[0];
    }

    $out = array();
...

I’ve not tested it, but the code means that if $val is 0 or not set, use the first item in the list as a default. This might cause a little weirdness on first install if a plugin alters the default increment steps. If ‘15’ is removed from the pageby list and instead offers: 10, 50, 100, 500, for example, the number of results will still be 15 on first view, because it’s hard-coded into all panels in the absence of a preference value. Upon first submission / alteration / search, the selected value will be stored in prefs and work from thereon. This is an acceptable trade off, imo.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2016-05-23 10:10:37

philwareham
Core designer
From: Farnham, Surrey, UK
Registered: 2009-06-11
Posts: 3,169
Website

Re: List number per page filters - default on install

I assume the list value is stored in the database? Couldn’t we simply set a default value of ‘15’ for these at initial install? That covers most cases.

Offline

#4 2016-05-23 10:28:27

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,611
Website

Re: List number per page filters - default on install

philwareham wrote #299211:

I assume the list value is stored in the database?

Yes, eventually. One value per panel, per user is built up as each person navigates the admin side.

Couldn’t we simply set a default value of ‘15’ for these at initial install?

For the admin user, yes. We could hardcode the 15 into the setup or adduser calls so a full suite of prefs for every panel are populated in readiness with a default value. But that requires adding a hard-coded list of available panels and / or the pref keys that need setting, which is more invasive and difficult to maintain than simply defaulting to the first item and hoping that a plugin hasn’t tinkered with the values.

Incidentally, the selected value would still be ‘wrong’ if a plugin was installed at any time and it changed the pagination steps. On first load of any page after the plugin was installed, the previous pagination value would still be read from the DB and, in that case, would select no item in the UI pagination list because it doesn’t match the stored value. And the number of shown records in the panel would reflect the old stored value. It could be argued this is a “correct” visual display: no values match, so nothing is selected in the paginator. But whether that’s aesthetically pleasing or not, is open to interpretation.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2016-05-23 11:15:34

philwareham
Core designer
From: Farnham, Surrey, UK
Registered: 2009-06-11
Posts: 3,169
Website

Re: List number per page filters - default on install

OK, please do whatever is the most simple!

Offline

Board footer

Powered by FluxBB