We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1008
    • 19 Posts
    I was wondering if anyone knows how to create a template for the &tplPaginateNext and tplPaginatePrevious links. The documentation is empty on that topic.ß
      • 1122
      • 209 Posts
      This issue is explained on Ditto support site at http://ditto.modxcms.com/files/snippet-ditto-php.html#tplPaginateNext

      tplPaginateNext
      Purpose
      Template for the next link
      Options
      Any valid chunk name
      Code via @CODE
      File via @FILE
      Placeholders
      url URL for the next link
      lang:next value of ‘next’ from the language file
      You should pass via &tplPaginateNext the name of a chunk containing your definition for next link, for example: &tplPaginateNext=`NextLink`.

      In order to build a template, you need just one thing -- url of the link -- and it is given for you as placeholder. Example of NextLink-chunk itself:
      <a href="[+url+]">Next Page</a>
      

      Apart from url placeholder Ditto also offers you lang:next placeholder that you can use instead of your static text ’Next Page’. In this case, Ditto will substitute it for an apropriate value from language file:
      <a href="[+url+]">[+lang:next+]</a>
      
        • 11681
        • 98 Posts
        For alexmglover and other readers of this thread,

        I spent a long time trying to get Ditto’s &tplPaginateNext and &tplPaginatePrevious to work. I wanted to substitute words for the default "Next" and "Previous" that would make more sense in a list of future events sorted on my own Date template variable. Yet I didn’t want to overwrite the default words in the language file.

        Let me save hours of experimenting. As Alik suggests, create named Chunks for these Ditto parameters. I never was able to make the inline alternative work properly:
        &tplPaginateNext= `@CODE <a href="[+url+]">Later</a>`
        &tplPaginatePrevious= `@CODE <a href="[+url+]">Sooner</a>`
        

        The Chunks work properly with no fuss, and they match the code you would find by tracing Ditto’s operation and looking at the HTML that Ditto emits.

        Please post if you figure out how to make parameters &tplPaginateNextOff and &tplPaginatePreviousOff work. If you refer to Ditto documentation at
        http://ditto.modxcms.com/files/snippet-ditto-php.html#tplPaginateNextOff,
        you’ll find that these closely related parameters are described quite differently from one another, which adds to the confusion. I gave up trying to use them and instead simply suppressed the vestigial "Next" and "Previous" as follows:
        &paginateAlwaysShowLinks= `0`

        Regards,
        Halfnium
          I looked just like that in 1964.
          • 1122
          • 209 Posts
          Inline code (@CODE) should not be used in this case at all, because it leads to ambiguity

          &tplPaginateNext=`@CODE <a href="[+url+]">Later</a>`

          Equal character has special meaning for snippet parser -- parser probably uses it to split the parameter into name and value parts. Place your code into regular chunks and it will work instantly.
            • 8345
            • 147 Posts
            Hey, I used the templates and it works only when "Previous" or "Next" is a link. For example when there’s two pages and I’m on a first page then the "Previous" is not a link and is called "Previous" and "Next" is a link and is called "My next text"

            On second page it’s opposite - there’s previous a link and "My previous text" and next is not a link and just "Next" not "My next text".
              • 1122
              • 209 Posts
              It looks like you did not set up templates for inactive elements. Full customization of Ditto’s pagination requires setting up six parameters (+ respective chunks containing templates for specific components of page navigator):
              &tplPaginatePrevious=`<chunk-for-prev-link>`
              &tplPaginatePreviousOff=`<chunk-for-prev-inactive>`
              &tplPaginatePage=`<chunk-for-page-link>`
              &tplPaginateCurrentPage=`<chunk-for-page-inactive(currently-selected)>`
              &tplPaginateNext=`<chunk-for-next-link>`
              &tplPaginateNextOff=`<chunk-for-next-inactive>`
              
                • 8345
                • 147 Posts
                Thanks a lot:) Of course that helped.