Custom pagination numbers aren't lining up
I'm getting a weird issue with a custom pagination component I'm trying to build. I have two tab items that I'm using a URL parameter to switch between. For each tab I'm using Freemarker to determine which tab is displaying and then build a feed of messages based on that. With the pagination, here's my code:
<#if tabParam = "latest">
<#assign pageSize=settings.name.get("layout.messages_per_page_linear")?number />
<#assign pageNum=webuisupport.path.parameters.name.get("page", 1 ) />
<#assign paginationOffset=(pageNum - 1) * pageSize />
<#include "forum_feed_macro" />
<#assign msgCountQry=rest("2.0","/search?q=" + "SELECT count(*) FROM messages WHERE board.id='${currentBoard}' AND depth=0"?url).data.count />
<#assign res = liql(rest_20, "SELECT ${querySelect} FROM messages where board.id = '${currentBoard}' AND depth=0 ORDER BY post_time desc LIMIT ${pageSize} OFFSET ${paginationOffset}") />
<@renderListResponse type="message" response=res render=messageRenderFullMessage />
<#assign pageable_item=webuisupport.paging.pageableItem.setCurrentPageNumber(pageNum).setItemsPerPage(pageSize).setTotalItems(msgCountQry?number).setPagingMode("enumerated").build />
<@component id="common.widget.pager" pageableItem=pageable_item />
</#if>
<#if tabParam = "activity">
<#assign pageSize=settings.name.get("layout.messages_per_page_linear")?number />
<#assign pageNum=webuisupport.path.parameters.name.get("page", 1 ) />
<#assign paginationOffset=(pageNum - 1) * pageSize />
<#include "forum_feed_macro" />
<#assign msgCountQryAll=rest("2.0","/search?q=" + "SELECT count(*) FROM messages WHERE board.id='${currentBoard}'"?url).data.count />
<#assign res = liql(rest_20, "SELECT ${querySelect} FROM messages where board.id = '${currentBoard}' ORDER BY post_time desc LIMIT ${pageSize} OFFSET ${paginationOffset}") />
<@renderListResponse type="message" response=res render=messageRenderFullMessage />
<#assign pageable_item=webuisupport.paging.pageableItem.setCurrentPageNumber(pageNum).setItemsPerPage(pageSize).setTotalItems(msgCountQryAll?number).setPagingMode("enumerated").build />
<@component id="common.widget.pager" pageableItem=pageable_item />
</#if>
My problem here is that the feed created within the second "if" statement, the pagination stops at page 8, even though it's displaying up to 25 pages available. The first section, however, does stop at page 8. I'm wondering if somehow something is getting crossed between the first and second sections.
For reference, the variables in the second feed are as follows:
- "pageSize" = 4
- msgCountQryAll = 98
I just don't understand what's going on with my code that's causing the pagination in the second section to get stuck at page 8 even though it's showing up to 25 pages in the pagination component.