We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
Subscribe: RSS
  • Hi there,

    When I set the limit of my getPage call to limit=`10` and there are only 5 results to display the pagination gives me an empty second page. How can I prevent this?

    I am using modx revo 2.2 and getPage 1.2.2

    - MIM [ed. note: MIM last edited this post 9 years, 10 months ago.]
    • How many total items does it say are being returned? Are the Resources you are paginating through (I assume via getResources) protected by any Resource Groups?
      • Hi,

        This is my call (I also tried it with the standard call, same result, an empty second page):

        [[!getPage? &elementClass=`modSnippet` &element=`getResources` &limit=`10` &parents=`10` &includeTVs=`1` &includeContent=`1` &tpl=`newsSummaryTpl` &tplLast=`newsSummaryTplLast`]]

        All pages in the parent folder are visible.

        It returns a total of 4 pages and that is exactly the amount of pages in the parent folder.

        - MIM
        • Getting the same error ... total results are three ...

          I placed a placeholder [[+total]] ... on the first page it displays '3' on the next or any other it displays '4' but the navigation is not displayed. Any ideas?

          The snippet has the limit and offset and built in and displays the results appropriately. In fact, the combination with getPage shows the correct results. i.e. If I click the navigation from the first page to go to the second page I get the second item and so on but its only the navigation that is not displayed


            <div class="paging">  
              <ul class="pageList">  


          Figured the issue ... I had performed the getCount after the limit. Worked when I did this;

          /* Get snippet properties and set the defaults */
          $limit      = $modx -> getOption('limit',$scriptProperties, 10);
          $offset     = $modx -> getOption('offset', $scriptProperties, 0);
          // get total count of query
          $total  = $modx -> getCount($albumObject, $query);
          // if limit or offset is set
          if (($limit != 0) || ($offset != 0)) {
            $query -> limit($limit,$offset);
          [ed. note: jobkingori last edited this post 9 years, 7 months ago.]