We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9995
    • 1,613 Posts
    I have a dittocall like this:

    [[Ditto? 
    &parents=`5`
    &total=`99`
    &showPublishedOnly=`1` 
    &orderBy=`menuindex ASC` 
    &tpl=`detail`
    &tplCurrentDocument=`detail-actief`
    &summarize=`9`
    &paginate=`1`
    &paginateAlwaysShowLinks=`1`
    ]]
    
    <div class="ditto_pages">Page [+pages+]</div>
    
    



    When I'm on page 1 all the 1st page ditto links need to add ?start=0
    When I'm on page 2 all the 2nd page ditto links need to add ?start=9
    on page 3 the ditto links need to add ?start=18...

    In chunk detail-actief I need somehow to use a math or other way.
    <a href="[~[+id+]~]?start=[+ditto_iteration:math=`(?)`+]">some link</a>


    I have found something but couldn't get it to work:
    http://forums.modx.com/thread/70785/making-ditto-iteration-consecutive-across-multiple-pages#dis-post-397440




      Evolution user, I like the back-end speed and simplicity smiley
      • 4041
      • 788 Posts
      Maybe something like this (untested) snippet:

      create a new snippet with the code below (named whatever you like, for this example it's named "DittoDetails").

      replace your existing ditto snippet call with the new snippet.
      [[DittoDetails]] or [!DittoDetails!]

      modify your detail-actief chunk like shown in the top of code.
      <?php
      /*    DittoDetails
      
      chunk detail-actief:
      
      <a href="[~[+id+]~][+start_page_var+]">some link</a>
      
      */
      
      // how many documents to summarize
      $ditto_summarize = '9';
      
      // get the chunk
      $detail_actief = $modx->getChunk( 'detail-actief' );
      
      // determine the start page
      // if start is empty, defaults to 0
      $start_page = ( !isset( $_GET['start'] ) ? '0' : intval( $_GET['start'] ) + $ditto_summarize );
      
      // determine initial url var seperator
      $url_sep = $modx->config['friendly_urls'] =='0' ? '&' : '?';
      
      // populate the [+start_page_var+] placeholder links in the chunk code
      $detail_actief = str_replace( '[+start_page_var+]', $url_sep.'start='.$start_page, $detail_actief );
      
      // set up the ditto snippet params
      $ditto_params = array(
          'parents'                  => '5',
          'total'                    => '99',
          'showPublishedOnly'        => '1',
          'orderBy'                  => 'menuindex ASC'
          'tpl'                      => 'detail',
          'tplCurrentDocument'       => '@CODE:'.$detail_actief,
          'summarize'                => $ditto_summarize,
          'paginate'                 => '1',
          'paginateAlwaysShowLinks'  => '1'
      );
      
      $output ='';
      
      // get the snippet output
      $output = $modx->runSnippet( 'Ditto', $ditto_params );
      
      return $output;
      ?>
      [ed. note: breezer last edited this post 10 years, 10 months ago.]
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 4041
        • 788 Posts
        I changed the code posted above, in case you tried the first version, the newest does the placeholder replacement before the snippet is run.
          xforum
          http://frsbuilders.net (under construction) forum for evolution
          • 9995
          • 1,613 Posts
          Hey Breezer,

          Hmmz, I forgot I had a custom snippetcall before calling your snippet.

          I found a typo: 'menuindex ASC',
          Now it does work, but there are some things that are wrong.

          I will show you the URL PM if you don't mind to see what I like to accomplish.
            Evolution user, I like the back-end speed and simplicity smiley