We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47243
    • 30 Posts
    Hi,
    not sure about the vocabulary.
    I'm new to MigX and just spent 10 hours trying to do that.
    Thought I would share it here.

    First of I have myTemplate which has a migx TV which I will call "myParentMigxTV".

    myParentMigxTV
    ==============
    Name : "myParentMigxTV"
    Template Access : check "myTemplate"
    Input Type : migx
    Form Tabs:
    [
    {"caption":"My Galleries","fields": [
            {"field":"title","caption":"Title","inputTVtype":"text"}
            {"field":"images","caption":"Upload images","inputTV":"myChildMigxTV.download"},     
    ]}
    ]

    Grid Columns:
    [
    {"header": "Title", "width": "2", "sortable": "true", "dataIndex": "title"},
    {"header": "My Galleries", "width": "2", "sortable": "true", "dataIndex": "images"}
    ]


    I am now able to add a gallery with its title and a bunch a images.
    Now let's configure "myChildMigxTV.download".

    myChildMigxTV.download
    ==============
    Name : "myChildMigxTV.download"
    Template Access : none
    Input Type : migx
    Configurations : "file.download"

    Now we must create the configuration file. this Link will help you do so http://rtfm.modx.com/extras/revo/migx/migx.tutorials/migx.use-resource-specific-mediasource-and-multifile-uploader.

    Upload some sample images.
    Now let's do the front end.

    Insert in myTemplate the following shortcode:

    [[!getImageList?
    &tvname=`myParentMigxTV`
    &tpl=`myParentMigxTemplate`
    &processTVs=`0`
    ]]	


    myParentMigxTemplate.chunk :

    <div class="myGallery">
    <h1>[[+title]]</h2>
    <ul>
    [[!parseMIGXToGallery? &tpl=`myMigxImageGallery.template` &input=`[[+images]]`]]
    </ul>
    </div>


    Now let's create the parseMIGXToGallery snippet (you can find the original code there :https://www.markhamstra.com/modx/2012/04/managing-galleries-with-migx/ ) :

    parseMIGXToGallery

    <?php
    $input = $modx->fromJSON($input);
    $output = array();
    //if (!$input || empty($tpl)) return 'no stuff';
    foreach ($input as $row) {  
      $output[] = $modx->getChunk($tpl, $row);
    }
    return implode("\n", $output);


    And now the corresponding chunk:

    myMigxImageGallery.template
    <li>
      [[migxResourceMediaPath? &pathTpl=`assets/gallery/{id}_{alias}/`]][[+image]]
    </li>


    I let you do the html for displaying the image.

    "[[migxResourceMediaPath? &pathTpl=`assets/gallery/{id}_{alias}/`]]" is the path where your images are uploaded (see http://rtfm.modx.com/extras/revo/migx/migx.tutorials/migx.use-resource-specific-mediasource-and-multifile-uploader for more inforamtions)

    that's it.


    I ended up with this solution because i was having torubles with calling getImageList within a chunk that was already called by getImageList. [ed. note: robotpapier last edited this post 11 years, 11 months ago.]
      • 28042 ☆ A M B ☆
      • 24,524 Posts
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 47243
        • 30 Posts
        thanks!
        been through a lot of forum but couldn't find those one!
        It was that simple...^^
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          It's all in knowing the terminology, and in using Google instead of the forum search field. Try Google, with "site:forums.modx.com nested migx" and you'll get all kinds of useful results.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org