Skip to content
Josh edited this page Jan 20, 2018 · 8 revisions

Parameters

$prefix $usecustomprefix $packageName

prepareQuery - properties:

$limit $offset $totalVar $where $queries $sortConfig $groupby $joins $selectfields $classname $debug

renderOutput - properties:

$tpl $wrapperTpl $toSeparatePlaceholders $toPlaceholder $outputSeparator $placeholdersKeyField $toJsonPlaceholder $jsonVarKey $addfields

Examples

Basic usage

(prints out the raw object)

[[migxLoopCollection?
    &packageName=`list-of-something`
    &classname=`list-of-something`
]]

Selects the id and pagetitle of all modResources under the parent 3 and saves it to placeholder "json"

[[migxLoopCollection? 
    &classname=`modResource`
    &selectfields=`id,pagetitle`
    &where=`{"parent":"3"}`
    &toJsonPlaceholder=`json` 
]]
[[+json]]

Selecting from a customPackage and sorting it by its position-field:

[[migxLoopCollection?
    &packageName=`customPackage`
    &classname=`CustomPackage`
    &tpl=`CustomPackageItem`
    &sortConfig=`[{"sortby":"position","sortdir":"ASC"}]`
]]

Selecting from a customPackage and inserting two additional placeholders via the 'addfields' parameter. This example adds a placeholder called 'field1' with value of 'one' and a placeholder called 'field2' with value of 'two'. These placeholders can then be used in the tpl via the placeholders [[+field1]] and [[+field2]].

[[migxLoopCollection?
    &packageName=`customPackage`
    &classname=`CustomPackage`
    &tpl=`CustomPackageItem`
    &addfields=`field1:one,field2:two`
]]

Note: The position-field has to be of type int for the sorting to work properly. This is also needed when using the this.renderPositionSelector renderer on such a column.

Notes

Right now migxLoopCollection is not aware of used media-sources for images in the config.

To work around this you will need to add an output modifier:

$output = str_replace('./','',$input);
if ($mediasource = $modx->getObject('sources.modMediaSource',$options)){
    $output = $mediasource->prepareOutputUrl($output);
}
return '/' . $output;

And then call it on your image like:

[[+image:addmediasourcepath=`2`]]