We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21739
    • 49 Posts
    I currently have thousands of products spread over a tree with multiple parents.
    Now my client wants to be able to "connect" several hundreds of products to one specific page. Since the order in which the items are connected should also be customizable (via drag 'n drop), the standard multi select tv type doesn't suffice. Ultimately, at this specific page, I'll simply be listing the connected resources via their ID's through getResources or similar.

    Would it be somehow possible to use Migx to create the following resource-selection-flow:

    1. "Add item button" displays a type ahead, multiselect field, not only showing the title but also a thumbnail (from TV) en the description of a bunch of resources fetched via @SELECT or @EVAL (similar to the "galleryalbumlist" tv type, from the gallery addon).
    2. After a bunch of items are selected, they are displayed in the migx grid in which the order of the resources can be altered.
    3. The output doesn't have to contain all the info as displayed in the selection query, a simple array of ID's would suffice.

    Unfortunately I'm on a tight deadline, so any practical input would be much appreciated.
    Or, if there is an alternative way to achieve this, please let me know.

    Thnx! [ed. note: nondotzero last edited this post 13 years, 7 months ago.]
      • 14883 ☆ A M B ☆
      • 450 Posts
      I've been pondering a sort-of similar use of MIGX - to build & maintain a large (dozens to hundreds) list of email addresses. The reason I say it is similar is that both problems need to manage a large list of things. My hesitance with MIGX is that although it seems pretty great for managing (adding, editing & removing itmes from) an existing list of (lots of) things, its "one-by-one" approach isn't very user friendly for initially *building* the list.

      What I've been pondering is a way to quickly initially populate the MIGX TV from something like a .csv file. This would save the work of manually adding potentially hundreds of items to the list. Then you could use MIGX's functionality to fine-tune the list, sorting, adding items here and there, etc. I'm wondering if anyone has done something like that with MIGX.

        • 4172
        • 5,888 Posts
        Its of course possible to add multiple migx-items programmatically.
        See this one for an example:
        http://rtfm.modx.com/display/ADDON/MIGX.Use+resource-specific+mediasource+and+multifile-uploader

        here we read files from a mediasource-directory and import them add once into MIGX
        by clicking a button.

        Its possible to add custom-buttons above the migx-grid, which can call custom-processors for doing stuff like that.

        It should also be possible to fill the MIGX-grid with initial content by using @EVAL - binding in its default-value
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 21739
          • 49 Posts
          It seems that Migx has all the components I need.

          Creating a custom processor to fetch modx resources will be a different matter however since I have no clue how I would have to tweak the loadfromsource.class.php file to do just that.

          In my case, the ID of the current page would be used to find resources with a tv value matching that ID (they are used as tags on other resources). The eventual return would be a migx grid filled with the id, title & image from tv.

          Any pointers would be appreciated! [ed. note: nondotzero last edited this post 13 years, 7 months ago.]
            • 21739
            • 49 Posts
            Quote from: Bruno17 at Mar 12, 2013, 03:23 PM
            It should also be possible to fill the MIGX-grid with initial content by using @EVAL - binding in its default-value

            I seem to be unable to do that.

            Default value: [{"MIGX_id":"1","title":"test","image":"test.jpg"}] -> works
            Default value: @EVAL $a = '[{"MIGX_id":"1","title":"test","image":"test.jpg"}]'; return $a; -> isn't executed?

            Am I missing something here?
              • 4172
              • 5,888 Posts
              the default-value (and the result of @EVAL) is only used as long as the TV-value is empty.
              And if there are new items you will need to add them manually.

              For this reason I think a 'load' or 'refresh' - button like the loadFromMediaSource - button would be the better option.
              If that's the case, I will look into it and post how its possible to add a new button which does that, but I need to know exactly,
              which informations from where you want to grab into the MIGX - grid.
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 21739
                • 49 Posts
                I simply want to fill up the migx grid with resources from a specific parent, filtered by a where "myTV==$modx->resource->get('id')". In other words, return all "other resources" where a TV value matches the ID of the current resource.

                The migx grid would contain the title, desc & imageTV of the resources matching the above.

                With this result, the user would not only be able to have an overview of the related resources, but he would also be able to manage the order using drag & drop (in my case, 100's of items).

                From this user ordered migx grid, I would output a list of sorted ID's which I can then return to getRecources or whatever to generate a front-end list.

                Tricky part: such a "refresh" or "load" button isn't allowed to empty & refill the contents of the entire grid because that way you would lose the manually ordered list. It would only be allowed to add or remove options for sorting whilst keeping the current order. (New items -> added at the bottom, Removed items -> deleted from the grid).


                Currently I've managed to do something similar using the "Checkbox sortable TV type":

                TV: input type "Checkbox sortable".
                Input options: @EVAL return $modx->runSnippet('theSnippetBlow');
                
                <?php 
                $myFilter = 'veiling==='. $modx->resource->get('id');
                $list = $modx->runSnippet('getResources', array(
                'parents'=>'62',
                'tpl'=>'snippetWithPagetitleAndID',
                'includeContent'=>'0',
                'includeTVs'=>'1',
                'depth'=>'3',
                'showHidden'=>'1',
                'limit'=>'1000',
                'where' => '{"template:=":2}',
                'sortby' => '{"pagetitle":"ASC"}',
                'tvFilters' => $myFilter,
                'outputSeparator' => '||'
                ));
                return $list;


                Which results in the attached screenshot. It does perfectly what I need it to (it also keeps the order of the items when values are added or removed), unfortunately te "checkbox sortable" TV type cannot display more columns of specific info, for which migx would be perfect.

                I hope this is at all possible with migx?
                  • 4172
                  • 5,888 Posts
                  I think I have something for you.
                  It is done with MIGXdb not with MIGX and uses a custom-table to hold the selected resource-relations and its positions.
                  I will put together the pieces and post them here.

                  With this you will have a MIGXdb - TV on the source-page where you can select the resources where to show the source-page in the grid.(This is what you currently do with your TV)
                  It will create records in the relations-table.

                  On the target-page you will have another MIGXdb - TV where you have the preselected Resources and where you can activate them. Its also possible to publish/unpublish the relation
                  on both sides, the target-page and the source-page.On the target page in should be possible to select a new position in the grid for moving them to another position in the order.

                  In Addition there is a CMP where you can see all Relations between Resources.

                  [ed. note: Bruno17 last edited this post 13 years, 7 months ago.]
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 21739
                    • 49 Posts
                    Sounds great Bruno, thanks for your time!
                      • 4172
                      • 5,888 Posts
                      all Right.

                      Its beta, but should do all of it:

                      https://github.com/Bruno17/migxResourceRelations
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!