Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-03-20 00:26:39

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Admin interface tab paging in 4.7

There’s a trick I’m missing to paging.

I’m using the old function (which I understand is deprecated):

echo pageby_form($event,$pageby);

but although the paging number is actioned (i.e. 12, 24 etc), and the page refreshes with the correct number of articles, the new current paging number is not highlighted (i.e. active style applied). Only “12” is ever shown as active.

If I try the new system directly:

$paginator = new \Textpattern\Admin\Paginator($event);
echo $paginator->render();

I get the same symptoms.

Here’s the $_GET stuff:

event = adi_matrix_matrix_1
step = adi_matrix_matrix_1_change_pageby
qty = 24

And the adi_matrix_matrix_1_pageby preference sems to be set correctly each time.

Note that the tab is refreshing – as opposed to the Ajaxy thing that happens on the articles list tab.

Expert guidance would be much appreciated.

Offline

#2 2018-03-20 09:46:28

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,447
Website GitHub

Re: Admin interface tab paging in 4.7

Ahem, thanks for the report. Try this commit instead which passes the value into the Paginator. Sorry about that.

On reflection, whether this is the best way to do it, I’m not sure. The Paginator is just a class for creating the paging links and needs to be told – during render($val) – what value to use.

But in some way, the very act of instantiating the darn thing with an event and a step should be enough information to have a stab at fetching the correct paging value from the prefs. Allowing you to override the value at render time is fine, but I’d probably expect it to at least have a go at finding the right value first if it can.

I might see if I can add that, as it’ll save you passing the value in explicitly unless you absolutely need to override it.


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 2018-03-20 09:54:15

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Admin interface tab paging in 4.7

Bloke wrote #310143:

Ahem, thanks for the report.

Yep that’s fixed it, thanks.

Offline

#4 2018-03-20 10:56:11

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,447
Website GitHub

Re: Admin interface tab paging in 4.7

Actually, the current system works fine. It’s only legacy stuff that was affected and now fixed.

For anyone stumbling upon this thread, the way to read the current pagination value for any given panel is:

$paginator = new \Textpattern\Admin\Paginator('plugin-event', 'your-prefix');
$limit = $paginator->getLimit();

where:

  • plugin-event is the page (event) upon which you wish the value to apply.
  • your-prefix is the bit to use in the pref key before the _list_pageby. Usually it’s your plugin name, which may or may not be the same as your $event. If it is the same, you can omit the value and it’ll take on the given event.

Then use the $limit value as usual in the pager() function to get the pagination limits and page number. See any admin panel code for details.

To set the value in your change_pageby() step, just ensure that qty is passed via GET/POST, then call:

Txp::get('\Textpattern\Admin\Paginator', 'plugin-event', 'your-prefix')->change();

Same deal as before regarding the event/prefix. The Paginator will do the rest, and ensure the passed value is sanitized.


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

Board footer

Powered by FluxBB