We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34120
    • 236 Posts
    I thought this would be quite simple but it's proving to be a bit of a challenge. I'm using getResource with getPage for pagination, this is all working fine. The problem is I want to display information showing the total number of records and the number displayed on a particular page. Sort of like this:
    <p>showing [[+limit]] of [[+total]]</p>

    The problem arises when there are fewer records than the limit or on the last page where the remaining records are also likely to be less than the limit.

    I've looked at passing [[+pageCount]] and [[+total]] into a snippet where I can do the calculations but I can't get this to work. The calculations come out incorrect. I think this is something to do with the passed values being strings and not integers but I'm not sure.

    Any ideas?

    • You could use output modifiers
      [[+pageCount:greaterthan=`[[+limit]]`:then=`<p>showing [[+limit]] of [[+total]]</p>`]]
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 34120
        • 236 Posts
        Hi, thanks for the reply. It's been a while since I looked at this.

        I'm trying to use output modifiers to determine when a user is on the last pagination page.
        For example: I have 2 pages in total, when I'm on the last page the following is output fine:
        [[+pageCount]] output = 2
        [[+page]] output = 2 

        But if I try and compare these values nothing is output, eg:
        [[+pageCount:isequalto=`[[+page]]`:then=`show something`]]