V3.2.12 Backend Pagination

  1. List Pagination Error. Why any update or cancel form return to List cause to first page?

Hi @tommyctwu

When navigating using the page numbers on a list, the page number is now stored in the page URL instead of in the session. (Release Note 33: October CMS 3.2 - Page Finder Release - October CMS)

Take a look at the Redirect article here: Redirects - October CMS - 3.x

Inside forms if you want to redirect to the previous page (and keep the list pages numbers),
add the data-browser-redirect-back attribute to the Save and Close (Save and Back) button.
Adding the attribute will give the previous URL redirection priority.

<button
    type="button"
    data-request="onSave"
    data-request-data="close:1"
    data-browser-redirect-back
    data-hotkey="ctrl+enter, cmd+enter"
    data-load-indicator="Saving Person..."
    class="btn btn-default">
    Save and Back
</button>

Also, the Cancel button.

<span class="btn-text">
    or
    <a
        href="<?= Backend::url('october/test/people') ?>"
        data-browser-redirect-back>
        Cancel
    </a>
</span>

Thanks Samuel, It helps a lot.

Hi @daft,

I have orders and products with pivot data. When I update order I can add products (pivot) and there is pagination there. When I click second page in products relation pivot the page property is added to browser link. Now when I add product, the relation manager list is refreshed and is showing empty, because of page property in browser link. I donā€™t have access to relation manager buttons to add ā€œdata-browser-redirect-backā€.

Is there a way to fix this?

Iā€™m not sure that the data-redirect-browser-back attribute will help here. Can you reproduce it using the Test plugin? GitHub - octobercms/test-plugin: Playground for October CMS

I installed Test Plugin. Please go to Users ā†’ Update User ā†’ Tab Pivot Data

I donā€™t know how, but this list by default use rolePage in link, not default page, so the issue is not visible here.

But I see another issue here. Standard, Pivot Data, Pivot Model lists uses the same rolePage in link. Most lists will use the same name, so if you go to page 2 on first list, refresh page, then on all three list you are on 2 page. The solution here is to use customPageName for each list. Maybe this is worth mentioned on update guide: Release Note 33: October CMS 3.2 - Page Finder Release - October CMS

My initial issue can be fixed with this.

Second issue is that for manage property you cannot right now use customPageName, it is using default page.

Update: plugins/october/test/controllers/users/config_relation.yaml

roles_pivot:
    label: Role
    view:
        list: $/october/test/models/userrolepivot/columns_basic.yaml
        toolbarButtons: add|remove|create
        filter: $/october/test/models/role/scopes.yaml
        showSearch: true
        recordsPerPage: 1
        customPageName: rolesViewPage
    manage:
        list: $/october/test/models/role/columns.yaml
        filter: $/october/test/models/role/scopes.yaml
        showCheckboxes: true
        recordsPerPage: 1
        customPageName: rolesManagePage
    pivot:
        form: $/october/test/models/userrolepivot/fields_basic.yaml

In case of Pivot Data and Pivot Model they both use the same page name on manage list view so when you go to Pivot Data ā†’ Add Role ā†’ Go to 2 page, close modal, go to Pivot Model, add Role. You are here on 2 page, because both list uses the same page name.

Solution will be to make customPageName available in manage mode.

Also nice improvement will be that when customPageName is not set by developer to use by default: {relationName}Page.

Now that I think more, those issues relates to only relation lists.

I imagine situation where user A will send link to backend area with page=2 in link. Now when user B opens it and go to second tab, where is second list with only 1 record. This list will be empty.

EDIT:

I also noticed right now that when you specify customPageName it is not used unless it is present in link. I have specified for products list relation (view mode):

customPageName: productsViewPage

Now in the browser link I add ?page=2, refresh page and my products list is empty (it is probably using page instead of my specified productsViewPage name.

1 Like

Hi @daft,

did you need something more from me to replicate those issues I mentioned?

Hi @Renatio

Thanks for this! We have fixed the ā€˜pageā€™ bug where the page number leaks to lists without any page value specified, which had a fallback to the ?page query value. This fixes some of the issues described.

Regarding the manage page name, the intended behavior was to not include the selected page number in the URL, which means the page number is reset every time the manage screen is open.

However, we can do both.

  • By default, the manage mode has customPageName set to false which means the page number is not stored in the URL and paging is reset every time.

  • A developer can specify a customPageName for manage mode to persist the selection in the URL

  • By default, the view mode has customPageName to ā€œmodelPageā€ syntax (eg: camel_case(class_basename($this->relationModel).'Page')

Try this again in v3.2.18 when it is released.