Forum Discussion

PerBonomi's avatar
10 years ago

Custom pagination refuses to cooperate

Hi there. I'm basically using the same code as here:

http://community.lithium.com/t5/Developers-Discussion/Implement-custom-pagination/m-p/106695/

 

My code:

<#assign page_size = 4/>
<#assign page_number = webuisupport.path.parameters.name.get("page",1) />
<#assign total_articles = restadmin("/blogs/id/${coreNode.id}/messages/count/").value?number/>
<#assign pageable_item = webuisupport.paging.pageableItem.setCurrentPageNumber(page_number).setItemsPerPage(page_size).setTotalItems(total_articles?number).setPagingMode("trivial").build />
<@component id="common.widget.pager" 
pageableItem=pageable_item />

Problem is, no matter what I try, I can't get past page 1.

I click on "next" (hover shows URL/page/2), but I just end up on URL again.

 

Have a feeling the webuisupport path code isn't "finding" page 2 and just jumping to page 1, but how to fix it?

  • Hi PerBonomi,

     

    This might be the admin settings overriding issue.

     

    Please change this and check.

    Admin -> Discussion Style -> Blogs  -> Number of articles per page

     

    Let me know if this works.

     

    Regards,

    Mahesh

     

    If my post is helpful and answers your question, please give "Kudos" and "Accept it as a Solution."

  • PerBonomi - The issue seems to be in line 2, where you are specifying the page_number as 1, please remove this and keep it blank.

     

    <#assign page_number = webuisupport.path.parameters.name.get("page","") />

     

    Let me know if this works.

    • PerBonomi's avatar
      PerBonomi
      Boss

      Thanks for your reply. That 1 is just a fallback, if no page number is found. 

       

      If I remove the default 1, or make it blank, the page just errors out completely, and I don't even get page 1.

      • VarunGrazitti's avatar
        VarunGrazitti
        Boss

        PerBonomi - I just checked out it again, use this instead.

         

        <#if webuisupport.path.parameters.name.get("page")??>
        	<#assign page_number =  webuisupport.path.parameters.name.get("page")  /> 
        <#else>
        	<#assign page_number = 1  /> 
        </#if>

        I hope this helps.