The problem is not with the [+ditto_iteration+] placeholder, it's with the [+currentPage+] placeholder... that's coming out blank.... in the source code, the placeholder looks like it's actually supposed to include a prefix of the &id parameter, e.g. if your call was
[[Ditto? &id=`something` ... ]]
then the current page placeholder is uses the &id as a prefix, e.g. [+somethingcurrentPage+], but it's still not parsing... so that looks like a bug.
Just as a note, here's the line from the ditto class file, around line 1130:
$modx->setPlaceholder($dittoID."currentPage", $display);
A workaround here is to tie into the URL parameter that's passed in the pagination links and just use a Snippet to read that number and add the local iteration from [+ditto_iteration+] to it. The basic problem here is that on each page of results, [+ditto_iteration+] returns only the
local iteration, e.g. if you are displaying only 4 results per page, the [+ditto_iteration+] will be 0, 1, 2, or 3. What you are trying to achieve here is the
global iteration, i.e. on the first page, you want 0,1,2, or 3, but on the second page, you want 4,5,6 or 7.
Since Ditto's placeholder for this is either borked or incorrectly documented, we need to work around it with a Snippet.
Here's my Snippet, named
getGlobalIteration:
<?php
/*------------------------------------------------------------------------------
NAME: getGlobalIteration
DESCRIPTION:
This grabs a parameter from the url, e.g. &gallery_start, and then does simple
math to determine the iteration number of an item in the grand scheme of results,
i.e. the "global iteration"
See http://forums.modx.com/thread/70785/making-ditto-iteration-consecutive-across-multiple-pages
AUTHOR: Everett Griffiths www.fireproofsocks.com
@param string $key: the key in the $_GET array that contains the current offset
@param integer $i: the current iteration (from [+ditto_iteration+]
@return integer the iteration for this item amongst *all* results
------------------------------------------------------------------------------*/
if (!isset($key)) {
$key = 'gallery_start';
}
$local_iteration = 0;
if (isset($i)) {
$local_iteration = (int) $i;
}
$start = 0;
if (isset($_GET['gallery_start'])) {
$start = (int) $_GET['gallery_start'];
}
return $start + $i;
?>
So I can just put that into my chunks referenced by Ditto's &tpl parameters. E.g. here's my tpl chunk:
<li>
<a id="link[+id+]" href="[~[+id+]~]?gallery_start=[!getGlobalIteration? &i=`[+ditto_iteration+]`!]"><img src="[+patient_image1+]" width="291" class="thumbnail" title="[+pagetitle+]" alt="[+pagetitle+]" /></a>
<p style="width:291px;">[+pagetitle+]</p>
</li>
Note that the URL parameter "gallery_start" was used because the Ditto call used &id=`gallery`. If you are using a different &id parameter for ditto, you can adjust the call to getGlobalIteration by specifying the &key parameter.
Hope this helps.
[ed. note: Everettg_99 last edited this post 12 years, 6 months ago.]