We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29902
    • 72 Posts
    I want a page that shows almost all the resources with pagination but skip the first 5 resources. This is my code, but it wont "jump" over the first 5 resources. Pagination is working. What am I doing wrong?

      $output = $modx->runSnippet('getPage', array(
        'elementClass' => 'modSnippet',
        'element' => 'getResources',
        'parents' => $sid,
        'limit' => 5,
        'depth' => 1,
        'pageVarKey' => 'page',
        'totalVar' => 'total',
        'offset' => 5,
        'tpl' => 'tpl-Under-Side-Liste-Item',
        'showHidden' => 1,
        'pageFirstTpl' => '<li class="control"><a[[+classes]][[+title]] href="[[+href]]">Første</a></li>',
        'pageLastTpl' => '<li class="control"><a[[+classes]][[+title]] href="[[+href]]">Siste</a></li>',
        'pageNavOuterTpl' => '[[+prev]][[+pages]][[+next]]',
        'pageActiveTpl' => '<li[[+activeClasses]]>[[+pageNo]]</li>',
        'includeTVs' => 1
      ));
      ...I believed it was Friday...
    • getPage automatically determines the offset based on the limit and page being requested. Your attempts to set it to 5 are unfortunately futile.
        • 29902
        • 72 Posts
        How could I then trim away five results so that it will show all the other resources?
          ...I believed it was Friday...
        • Quote from: thorjarle at Dec 08, 2011, 02:47 PM
          How could I then trim away five results so that it will show all the other resources?
          You would need to exclude them from the total via where conditions for getResources or something, or we would need to add an initial offset feature to getPage so it could handle the calculations differently.
            • 37984
            • 215 Posts
            Any chance that you would be willing to update getPage to add this functionality? I am actually in need of the exact same thing: I need to skip the first six resources and start my pagination with the seventh.
              Jesse Couch
              MODX Aficionado, Front-End Designer & Developer
              http://www.designcouch.com
              • 19328
              • 433 Posts
              Hi thorjarle and designcouch, did you ever get this to work?
                • 19328
                • 433 Posts
                Hi all, I found a workaround and it seems to work for me. I'm posting it here for anyone interested.
                It requires a change in the getPage snippet.
                Around line 16, change the code to:
                $properties['offset'] = (!empty($properties['limit']) && !empty($properties['page'])) ? ($properties['limit'] * ($properties['page'] - 1)) + 1 : 0;


                For me, only one resource had to be skipped, that's why I added + 1. I guess you could add more here to skip more resources.

                Don't know if this is the best way to achieve this and will test more if it really works as expected.
                  • 37984
                  • 215 Posts
                  @michelle84, I combined your solution and Jason's - changed that line to:
                  $properties['offset'] = (!empty($properties['limit']) && !empty($properties['page'])) ? ($properties['limit'] * ($properties['page'] - 1)) + $initialOffset : 0;

                  and then included this in my getPage call:
                  $initialOffset=`1`

                  This allows you to customize the offset per call instead of hard coding it into the snippet. I don't see any reason why this couldn't VERY easily have been added to getPage by now - Jason?
                    Jesse Couch
                    MODX Aficionado, Front-End Designer & Developer
                    http://www.designcouch.com
                  • Sal Baldovinos Reply #9, 7 years ago
                    Quote from: designcouch at Oct 28, 2015, 10:30 AM
                    @michelle84, I combined your solution and Jason's - changed that line to:
                    $properties['offset'] = (!empty($properties['limit']) && !empty($properties['page'])) ? ($properties['limit'] * ($properties['page'] - 1)) + $initialOffset : 0;

                    and then included this in my getPage call:
                    $initialOffset=`1`

                    This allows you to customize the offset per call instead of hard coding it into the snippet. I don't see any reason why this couldn't VERY easily have been added to getPage by now - Jason?

                    How is this now core functionality smiley Thankfully Google + this forum helped solve my issue smiley
                      Sal Baldovinos
                      SEO & DIGITAL MARKETING

                      ARIEL DIGITAL | Maximize Your Potential
                      www.arieldigitalmarketing.com