We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36760
    • 136 Posts
    I'm on Modx Revolution 2.5.8-pl, with MIGX 2.11.0-pl. I've been using the below mergeMIGX snippet for awhile now, but I recently noticed only one entry per MIGX_id is shown, despite all entries being shown in the raw output [property.value].

    // From: https://forums.modx.com/thread/41006/migx---multiitemsgridtv-for-modx---revolution?page=18#dis-post-395927
    // [[mergeMIGX? &tvname=`mymigxtv` &docids=`10,11,12` &tpl=`mytpl` &debug=`1`]]
    
    $docids = explode(',', $docids);
    if ($tv = $modx->getObject('modTemplateVar', array('name' => $tvname))) {
        $allitems = array();
        foreach ($docids as $docid) {
            $outputvalue = $tv->renderOutput($docid);
            $items = $modx->fromJSON($outputvalue);
            if (is_array($items)) {
                $allitems = array_merge($allitems, $items);
            }
            elseif ($debug) {
                echo 'Error in '.$docid.': '.$outputvalue;
            }
        }
        $scriptProperties['value'] = $modx->toJSON($allitems);
    }
    
    return $modx->runSnippet('getImageList', $scriptProperties);


    The information being passed to the snippet:
    [[mergeMIGX? &tvname=`guideChangeLog` &docids=`195,194,191,189,185,183,180,172,167,168,159` &limit=`1000` &sort=`[{"sortby":"date","sortdir":"DESC"}]` &debug=`1`]]

    The debug information returns the page ID's that have no guideChangeLog entries, removing those ID's doesn't have any affect on the MIGX_id issue.

    The raw output for one entry looks like this.
    Array
    (
        [MIGX_id] => 1
        [date] => 2017-03-23 00:00:00
        [change] => Goroth healer guide added.
        [resource-id] => 159
        [_alt] => 1
        [_first] => 
        [_last] => 1
        [idx] => 24
        [property.tvname] => guideChangeLog
        [property.docids] => 195,194,191,189,185,183,180,172,167,168,159
        [property.limit] => 1000
        [property.sort] => [{"sortby":"date","sortdir":"DESC"}]
        [property.value] => [{"MIGX_id":"1","date":"2017-10-05 01:44:53","change":"Added Mythic kill video and clarified Mythic information.","resource-id":185},{"MIGX_id":"1","date":"2017-03-23 00:00:00","change":"Goroth healer guide added.","resource-id":159},{"MIGX_id":"2","date":"2017-03-27 00:00:00","change":"Added Demonic Inquisition healer guide.","resource-id":159},{"MIGX_id":"3","date":"2017-04-28 00:00:00","change":"Added Harjatan healer guide.","resource-id":159},{"MIGX_id":"4","date":"2017-05-15 00:00:00","change":"Added Sisters of the Moon healer guide.","resource-id":159},{"MIGX_id":"5","date":"2017-05-22 00:00:00","change":"Added Mistress Sassz'ine healer guide.","resource-id":159},{"MIGX_id":"6","date":"2017-06-08 00:00:00","change":"Added Maiden of Vigilance healer guide.","resource-id":159},{"MIGX_id":"7","date":"2017-06-13 00:00:00","change":"Added Fallen Avatar healer guide.","resource-id":159},{"MIGX_id":"8","date":"2017-06-19 00:00:00","change":"Added Kil'jaeden healer guide.","resource-id":159},{"MIGX_id":"9","date":"2017-06-22 00:00:00","change":"Reviewed the first seven healer guides, made minor wording adjustments or clarifications.","resource-id":159},{"MIGX_id":"10","date":"2017-06-25 00:00:00","change":"Goroth healer guide updated with DBM settings, kill video, and in-depth strategy notes.","resource-id":159},{"MIGX_id":"11","date":"2017-06-26 00:00:00","change":"Demonic Inquisition healer guide updated with DBM settings, kill video, and in-depth strategy notes.","resource-id":159},{"MIGX_id":"12","date":"2017-06-26 00:00:00","change":"Harjatan healer guide updated with DBM settings, kill video, and in-depth strategy notes.","resource-id":159},{"MIGX_id":"13","date":"2017-06-27 00:00:00","change":"Sisters of the Moon healer guide updated with DBM settings, kill video, and in-depth strategy notes.","resource-id":159},{"MIGX_id":"14","date":"2017-06-28 00:00:00","change":"Mistress Sassz'ine healer guide updated with DBM settings, kill video, and in-depth strategy notes.","resource-id":159},{"MIGX_id":"15","date":"2017-06-29 00:00:00","change":"Desolate Host healer guide updated with DBM settings, kill video, and in-depth strategy notes.","resource-id":159},{"MIGX_id":"16","date":"2017-07-02 00:00:00","change":"Fallen Avatar healer guide updated with DBM settings and kill video.","resource-id":159},{"MIGX_id":"17","date":"2017-07-03 00:00:00","change":"Updated Kil'jaeden healer guide with DBM settings and minor ability clarifications.","resource-id":159},{"MIGX_id":"18","date":"2017-07-04 00:00:00","change":"Added kill video to Kil'jaeden healer guide.","resource-id":159},{"MIGX_id":"19","date":"2017-07-07 00:00:00","change":"Added in-depth notes to Maiden of Vigilance healer guide.","resource-id":159},{"MIGX_id":"20","date":"2017-07-13 00:00:00","change":"Kil'jaeden healer guide updated with in-depth notes.","resource-id":159},{"MIGX_id":"21","date":"2017-07-25 00:00:00","change":"Updated Mythic information in the Goroth and Harjatan healer guides. Added Mythic kill video to Harjatan guide.","resource-id":159},{"MIGX_id":"22","date":"2017-08-08 00:00:00","change":"Added a mythic kill video and additional mythic information to the Sisters of the Moon healer guide.","resource-id":159},{"MIGX_id":"23","date":"2017-08-29 00:00:00","change":"Added Mythic video to the healer guide for The Desolate Host.","resource-id":159}]
    )

    Under [property.value], all entries are listed as expected, however, only one of the two entries with "MIGX_id":"1" are shown as a separate entry in the output.

    I'm guessing this has to do with how getImageList is setup, but I'm hoping there's a way around it. I did some searching for "duplicate MIGX_id" and couldn't find anything. I also paged through the old MIGX thread for more mergeMIGX information and didn't come up with anything new.

    I appreciate the help!

    This question has been answered by Bruno17. See the first response.

    • discuss.answer
      • 4172
      • 5,888 Posts
      try
      &placeholdersKeyField=``
      


      this is the array-key for the output-array, which is usually the value of 'MIGX_id'
      with the property above, the key is a autoincrementing value
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!