pdoTools
pdoTools copied to clipboard
pdoResources &first not working as advertised
I've been trying to use the &first
parameter to change the starting number for the [[+idx]]
placeholder within my template, but it seems to be ignored.
I've tried to find out if it is somehow my fault, but for me it seems that pdoFetch::run()
which is at thecore of the [[pdoResources...]]
snippet simply assigns [[+idx]]
as:
$row['idx'] = $this->idx++;
(in line 135 of core/components/pdotools/model/pdotools/pdofetch.class.php)
which acquires it's initial value like this:
if (!isset($this->config['idx']) || !is_numeric($this->config['idx'])) { $this->config['idx'] = 1; } $this->idx = !empty($this->config['offset']) ? (int)$this->config['offset'] + $this->config['idx'] : (int)$this->config['idx'];
(starting from line 63 of core/components/pdotools/model/pdotools/pdofetch.class.php)
So it looks like to me that the &first
parameter is ignored by this class.
Looking into it further, it looks like it is however being considered by the parent pdoTools
class. The defineChunk()
method looks to use this parameter to decide if it should use the normal template or &tplFirst
or &tplLast
.
Based on this my understanding is the &first
(and &last
) properties can be used to determine which template to use, not to start the IDX numbering at a specific number. Which is fair enough, however the documentation suggest it different to me:
&first | 1 | Number of the first item of the output results.
(https://docs.modx.pro/en/components/pdotools/snippets/pdoresources)
Could you please clarify it please?