Support

Account

Forum Replies Created

  • Hi @Elliot,

    You mentioned that the back-end pagination for repeater fields could be written with some simple code. Can you please elaborate on that?

    Is there any way I could add pagination, in the admin area, for the ACF box?
    Ideally, I would like to show ~50 items and then browse through the rest ajax-style or even with a page reload, it doesn’t matter. The fields would be displayed in reverse order, with the new ones at the top.

    I tried to edit the repeater file (advanced-custom-fields-pro/pro/fields/repeater.php) by altering the foreach( $field[‘value’] as $i => $row ) loop.

    This workaround seemed like a good fix until I tried to update the post, when all the data that isn’t displayed gets erased from the database. The meta key holding the total number of images also gets updated.

    Any advice on how I could achieve this kind of functionality?

    Thanks a lot!

  • Hi James,

    Thanks for the heads up – indeed, saving the post will erase all repeater fields, except for the ones shown.

    I’ll open a new ticket, maybe there’s an easier way to do this.

  • UPDATE:

    I managed to implement a very crude version of what I want to achieve, in case someone else needs it or wants to expand on it.

    I hardcoded the file advanced-custom-fields-pro/pro/fields/repeater.php, adding something like

    if($i < $lmin) continue;
    if($i > $lmax) continue;

    around line ~300, in the foreach( $field[‘value’] as $i => $row ) loop.

    $lmin and $lmax are URL parameters.

    Below the repeater listing I added “pagination” links

    <a href="URL[+]&lmin=0&lmax=50>See results 0-50</a>
    <a href="URL[+]&lmin=51&lmax=100>See results 51-100</a>
    ...

    I’ll keep looking into ACF’s beautifully written code to see if I can do this more elegantly, maybe without a page refresh.

    The bad thing is that these edits will be overwritten if the plugin is upgraded, so if someone can suggest a way to do this without meddling with the plugin code, that would be great.

    Some kind of hook like pre_get_posts for $field[‘value’] would be really useful.

Viewing 3 posts - 1 through 3 (of 3 total)