Skip to content

Mad/data archive bug#74

Open
mariel-delagarza wants to merge 3 commits intomainfrom
mad/data-archive-bug
Open

Mad/data archive bug#74
mariel-delagarza wants to merge 3 commits intomainfrom
mad/data-archive-bug

Conversation

@mariel-delagarza
Copy link
Copy Markdown
Member

@mariel-delagarza mariel-delagarza commented Jun 14, 2022

What

Fixing bug from #73

The default limit for number of posts per page is 10, and WordPress will fetch additional posts upon the user clicking the "next" pagination button. This is the pagination used on the temporary fix table. dataTables.js wasn't able to paginate because WordPress was only grabbing ten posts at a time.

Fix

  • Replace archive-data with content that had been moved to dataTable-archive-data.
    Copy content from old file and replace content of the temporary fix in archive-data.

  • Add new wp_query to the archive-data file.
    To fix the bug caused by WordPress not fetching all posts at once, create a new wp_query asking for all posts of type data and set -1 (no limit) for posts_per_page. Save this as $result and use this query in the if/while statements that create the table.

  • Remove aerospace_post_num() usage.
    Other archives use this function to render "PAGE X/Y" at the top and bottom of their pages. Because the data for this table is now fetched in advance, going to the next page of the table doesn't trigger a page re-render so the "PAGE 1/2" never updates to "PAGE 2/2". While php is removed, leave the divs in place so the styling isn't affected.

Video

Zoomed way out so it would fit on one screen without scrolling:

Screen.Recording.2022-06-14.at.3.54.00.PM.mov

Add a new wp_query to the archive-data file, replace archive-data
content with old content that had been moved to dataTables-archive-data.
The dataTables default for pagination is true, but forcing it by
declaring "paging": "true" helped fix the bug.
aerospace_post_sum is used to display "Page X/Y" at the top and bottom of the page. You can see it also used in the other archives (e.g. Aerospace 101). Because the data for the table is fetched in advanced, pagination through dataTables.js is not a true page refresh, so the aerospace_post_sum doesn't get triggered and "PAGE 1/2" does not update to "PAGE 2/2" when the user goes to the second page of the table.
With other updates, file doesn't need to have "paging" set to true in order to function properly. The default for dataTables pagination is already true.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant