We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41301
    • 10 Posts
    I've been looking all over for the answer to this question with no luck. I need to pass the integer value of +pagecount and +page over to a snippet so I'll be able to calculate rel=prev and rel=next. I tried using the call below, but the value does not pass into the snippet:

    [[!PaginationNextPrev? &currenturl=`[[++site_url]][[*id:isnot=`[[++site_start]]`:then=`[[~[[*id]]]]`]]` &totalpages=`[[+pageCount]]` &pagenum=`[[+page]]`]]

    can someone point me in the right direction? I assume it has something to do with modx->xxxx but my knowledge of that function is very novice.

    Thanks
    Chris

    This question has been answered by BobRay. See the first response.

    • discuss.answer
      • 3749
      • 24,544 Posts
      Is there some reason you can't use getPage's built-in prev and next links?

      Assuming that you can't . . .

      The +page and +pagecount placeholders won't be set until after getPage runs.

      I think I would create a simpler snippet with its tag below the getPage tag and use it to set my own placeholders:

      [[+prevLink]]   [[+nextLink]]


      I'd move most of what happens in your tag above into the custom snippet. Something like this:


      <?php
      
      $docId = $modx->resource->get('id');
      $siteStart = $modx->getOption('site_start');
      
      if ($docId != $siteStart) {
          $pageCount = $modx->getPlaceholder('pageCount');
          $page = $modx->getPlaceholder('page');
      
          /* Calculate what you want in the prevLink and nextLink placeholders here 
             based on $docId, $page, and $pageCount -- then set them in the 
             $prevLink and $nextLink variables 
          */
      
          $modx->setPlaceholder('prevLink', $prevLink);
          $modx->setPlaceholder('nextLink', $nextLink);
      }
      
      return '';
      
      
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 41301
        • 10 Posts
        Thank you!, that helped out a lot!

        I'm still fairly novice on Modx, but your website guide has been great help, so thank you for that too.
          • 3749
          • 24,544 Posts
          Thanks for the kind words. I'm glad I could help. smiley
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting