getImageList totalVar with migxfineuploader

In an image MIGX TV used by Newspublisher and stored via MIGXFineUploader, the totalVar [[+total]] placeholder outputs 1 with multiple images stored for the resource.

With [[+idx]] in the getImageList tpl, the count is correct.

From getImageList docs:
`[[+total]]`: count of all rows, replace 'total' with your totalVar

There are two total images in my example, hence I’d expect [[+total]] to output 2. Is this the right expectation?

do you have maybe another snippet at the same time, which also outputs a [[+total]] placeholder?
Then you need set another totalVar, for example &totalVar=`migxtotal` and the placeholder [[+migxtotal]]
Are you calling getImageList maybe uncached and the placeholder cached?

Everything uncached.

On the resource in question, no. However, setting totalVar to something other than the default results in the correct output.

Thanks!

One follow-up on this - can this placeholder be combined with output filters? This does not work:

[[!+migxtotal:isgt=`1`:then=`--left`]] when [[!+migxtotal]] outputs 2.

Where exactly do you use this placeholder?

If by any chance you use it in an @CODE: inline template, then move the template code to a proper chunk.

<!-- This doesn't work -->
[[!getImageList?
    ...
    &tpl=`@CODE:[[!+migxtotal:isgt=`1`:then=`--left`]]`
    &totalVar=`migxtotal`
]]

Thanks. The placeholder is in the resource template:

...
<div class="chart chart-container">
    <div class="chart-inner chart-inner--[[!+migxtotal]]">
        [[!getImageList? &docid=`[[*id]]` &tvname=`images` &tpl=`chart-thumb` &totalVar=`migxtotal`]]
    </div>
    [[*chartNotes:notempty=`<div class="chart-inner chart-inner--[[!+migxtotal]]">
        <h4>Session notes</h4>
        [[*chartNotes]]
    </div>`]]
</div>
...

I’m curious why the output filter doesn’t work as expected. The styling need, however, was solved via wildcard css selectors.

How the MODx parser really works is hard to grasp, but in your case the gist is, that you are trying to access a placeholder before it is set.


[[!+migxtotal:isgt=`1`:then=`--left`]]
[[!getImageList? &docid=`[[*id]]` &tvname=`images` &tpl=`chart-thumb` &totalVar=`migxtotal`]]

On line 1 the code tries to read the value of the placeholder migxtotal, but this placeholder is only set after the snippet getImageList has run.

When you swap the lines, it works:

[[!getImageList? &docid=`[[*id]]` &tvname=`images` &tpl=`chart-thumb` &totalVar=`migxtotal`]]
[[!+migxtotal:isgt=`1`:then=`--left`]]

Why does it work without the output filter?

[[!+migxtotal]]
[[!getImageList? &docid=`[[*id]]` &tvname=`images` &tpl=`chart-thumb` &totalVar=`migxtotal`]]

The parser handles simple placeholders differently. If no value for this placeholder is defined, the placeholder is left in place. The code does multiple iterations and on the second iteration, the value of the placeholder has been set and can be substituted.

Super helpful - thanks very much.

I would call everything cached, There is no reason to call it uncached.

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.