We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Bruno, you're a gentleman and a scholar. Thank you so much for your help.

    I got the latest version, imported your configs, and it works fine.

    Thanks once again for building this amazing tool!
    • I also think I see why I was having problems. I was still using MIGX 2.3.2 because the package manager did not register that it needed to be upgraded.
      • While we're at it - any tips for handling many-to-many relationships?
        • Sorry - let me make the question more specific. Here's how I normally handle many-to-many relationships:


          • Have separate CMPs for the related objects - that part is easy with MIGXdb
          • On the update form for one object, you have a multi-select box that pulls its data from the getlist processor for the related object. This allows you to select several of the related objects to associate with this object. Looks like I can do this in MIGXdb with an @SELECT binding (though I would be more comfortable doing it with a getlist processor for security reasons, the @SELECT binding works fine)
          • Write a custom update processor that extends the beforeSave method. It takes the values of the multi-select box and uses them to create the appropriate connector objects to connect this with the related objects selected. This part I'm not completely sure about how to do. It looks like I can specify my own processor path and write my own processors. But I really just want a custom update processor, I'm fine using the MIGX processors for everything else. So how do I add just a custom update processor, and just use the normal processors for delete etc?
          • Place a button next to the multi-select box for creating a new related object (in case the one you want doesn't already exist). This opens up the create form for the related object. When you save that form, the create processor creates the appropriate connector object to connect the new related object to this one. I think I can do that by creating a new grid.config.inc.php file that inserts the code for my custom button as described in this thread: http://forums.modx.com/thread/79496/migxdb-for-child-resources-make-edit-button-open-normal-edit-screen. That seems pretty straightforward, and I can have the button fire whatever JS I want, including opening up a create window for the related object

          So really I have two questions: first, does that sound like a reasonable way to do it, or is there something better I'm not thinking of? Second, how can I write my own custom processors for some actions and use the MIGXdb processors for the rest of the actions? Is that what the "Handlers" tab is for?
            • 4172
            • 5,888 Posts
            Using custom-processors in your MIGXdb-projects is very easy.

            Just create your custom-processor in your packages-folder under

            yourpackage/processors/mgr/default/

            or if you have defined a processorpath under

            yourpackage/processors/mgr/processorpath/

            and use this params, if you have custom-ajax-requests:

            { 
                    action: 'mgr/migxdb/process',
                    processaction: 'yourcustomaction',
                    configs: '[[+config.configs]]'
            }


            MIGX will search for the processor yourcustomaction.php
            1. under yourpackage/processors/mgr/processorpath/yourcustomaction.php
            2. under yourpackage/processors/mgr/default/yourcustomaction.php
            3. under migx/processors/mgr/processorpath/yourcustomaction.php
            4. under migx/processors/mgr/default/yourcustomaction.php

            but I think I wouldn't use a multiselect-box, but another MIGXdb-grid for selecting/creating the many/many - relationships.
            Did this several times and this is working great.
            You can filter and search for records, add additional ones, add additional infos to the relations, if you want.
            You can have a column with a special renderer and a nice cross/tick-icon for activating/deactivating publishing/unpublishing the relation.

            One example, which does something like that is this one:
            https://github.com/Bruno17/migxResourceRelations

            see this special processors in this example:

            https://github.com/Bruno17/migxResourceRelations/blob/master/core/components/migxresourcerelations/processors/mgr/default/activaterelation.php
            https://github.com/Bruno17/migxResourceRelations/blob/master/core/components/migxresourcerelations/processors/mgr/default/publishtarget.php



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

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
            • Thanks again Bruno, I owe you a favor. Let me know if there's something I can do to help with MIGX development.

              That's a good idea, using a grid. The example is really helpful too.

              I like the way you set it up to look for custom processors, so that if it doesn't find one it'll fall back on the defaults. That's quite clever.

              An idea occurred to me in working on this - it would be cool if there were an easy way to export an entire MIGX package (not just the JSON of the config, but the whole thing, as a transport package). Maybe when I get some time I'll work on setting such a thing up. It would be cool to have a library of MIGXdb packages similar to normal Extras.

              I think I have a good handle on how to do this now, I'll try to figure things out from here instead of bothering you ;-). Thanks so much...
              • Hi freejung;
                About creating a Package:
                It is easy to do. Bruno has built MIGx with this in mind. I have done it myself with a relative large project with relations, custom processors, etc and it works very good. You can use the Packman extra for this. Once you have your all your migx, migxdb working ok from /core/components/YOUR_COMPONENT and you have the Packman extra installed do the following:

                In the top menu go to Components, MIGx, MIGx Tab and right click on every row, Export on every Migx configuration of your project.
                This will create a .js file for every config under your /core/components/YOUR_COMPONENT/migxconfigs

                In the top menu goto Components, Packman.
                Name your Package in the first tab.
                In the Directories Tab add your core/components/YOUR_COMPONENT folder
                Optionally add core/assets/YOUR_COMPONENT or any other folder you think will be needed
                Use the other Tabs to export chunk, snippets, templates.

                To export template variables used in your project i suggest to use a new blank template and associate all TVs you use in the project and add this template in the Templates Tab (i will bring all associated TVs automatically)
                Before clicking on Export create a new Profile and name it as the name of your custom package and Save it. This way you can update later and augment the version of your package without doing the whole thing again.

                Then click on Export. This will create transport .zip file that you can use to install in another MODx instance uploading the .zip to the core/packages folder and going to Package Management/Search locally for packages so you can install from there as any other Extra.

                On the other MIGx instance once the package is installed you can go to MIGx, Package Manager Tab, load your package schema to make sure everything is ok and create the tables using the Create Tables Tab.
                Go to the MIGx Tab and import your configs using the Import from package button in the top of the grid and put the name of your component in the input box and all configs will imported to the system from physical config.js files stored in /core/components/YOUR_COMPONENT/migxconfigs

                Alternatively, you can you use the MyComponent Extra, but i haven't used before as Packman already works ok for me. [ed. note: lithiumlab last edited this post 10 years, 9 months ago.]
                • Thanks for that lithiumlab, that's very useful.

                  I do have a feature request, and if I get time I'll do it myself and submit a pull request:

                  It would be nice to have support for class-based processors, as the old style of processors have been deprecated.

                  Having said that, I've got my custom getlist processor working fine and everything seems to be going well.
                  • Hopping into this thread with a different wrinkle that I MUST be missing something basic.

                    I need to put a grid in a form tab, the data of which will be saved as a JSON string into a field ("specifications") of the Parent Class ("Catalog").

                    I assumed that I would create a new MIGXdb config for this ("productspecs") and just point this new config to the Catalog class. Doing this creates a new record instead of adding the data to the current record.

                    here are the configs to the Parent MIGX Config:
                    {
                      "formtabs":[
                        {
                          "MIGX_id":1,
                          "caption":"General",
                          "print_before_tabs":"0",
                          "fields":[
                            {
                              "MIGX_id":1,
                              "field":"prodno",
                              "caption":"Product Number",
                              "description":"",
                              "description_is_code":"0",
                              "inputTV":"",
                              "inputTVtype":"text",
                              "configs":"",
                              "sourceFrom":"config",
                              "sources":"[]",
                              "inputOptionValues":"",
                              "default":""
                            },
                            {
                              "MIGX_id":2,
                              "field":"prodname",
                              "caption":"Product Name",
                              "description":"",
                              "description_is_code":"0",
                              "inputTV":"",
                              "inputTVtype":"text",
                              "configs":"",
                              "sourceFrom":"config",
                              "sources":"[]",
                              "inputOptionValues":"",
                              "default":""
                            },
                            {
                              "MIGX_id":3,
                              "field":"description",
                              "caption":"Description",
                              "description":"",
                              "description_is_code":"0",
                              "inputTV":"",
                              "inputTVtype":"richtext",
                              "configs":"",
                              "sourceFrom":"config",
                              "sources":"[]",
                              "inputOptionValues":"",
                              "default":""
                            }
                          ]
                        },
                        {
                          "MIGX_id":2,
                          "caption":"Specifications",
                          "print_before_tabs":"0",
                          "fields":[
                            {
                              "MIGX_id":1,
                              "field":"specifications",
                              "caption":"Specifications",
                              "description":"",
                              "description_is_code":"0",
                              "inputTV":"",
                              "inputTVtype":"migxdb",
                              "configs":"productspecs",
                              "sourceFrom":"config",
                              "sources":"[]",
                              "inputOptionValues":"",
                              "default":""
                            }
                          ]
                        },
                        {
                          "MIGX_id":3,
                          "caption":"Images",
                          "print_before_tabs":"0",
                          "fields":[
                            {
                              "MIGX_id":2,
                              "field":"images",
                              "caption":"",
                              "description":"",
                              "description_is_code":"0",
                              "inputTV":"",
                              "inputTVtype":"migxdb",
                              "configs":"productimages",
                              "sourceFrom":"config",
                              "sources":"[]",
                              "inputOptionValues":"",
                              "default":""
                            }
                          ]
                        }
                      ],
                      "contextmenus":"update||duplicate||activate||deactivate||recall_remove_delete||remove",
                      "actionbuttons":"addItem||bulk",
                      "columnbuttons":"",
                      "filters":"[]",
                      "extended":{
                        "migx_add":"",
                        "formcaption":"Manage the catalog products in the grid below",
                        "update_win_title":"Product Catalog",
                        "win_id":"productcatalog",
                        "maxRecords":"",
                        "addNewItemAt":"top",
                        "multiple_formtabs":"",
                        "extrahandlers":"",
                        "packageName":"productcatalog",
                        "classname":"Catalog",
                        "task":"",
                        "getlistsort":"",
                        "getlistsortdir":"",
                        "use_custom_prefix":"0",
                        "prefix":"",
                        "grid":"",
                        "gridload_mode":1,
                        "check_resid":1,
                        "check_resid_TV":"",
                        "join_alias":"",
                        "has_jointable":"yes",
                        "getlistwhere":"",
                        "joins":"",
                        "cmpmaincaption":"Product Catalog",
                        "cmptabcaption":"Products",
                        "cmptabdescription":"  ",
                        "cmptabcontroller":"",
                        "winbuttons":"",
                        "onsubmitsuccess":"",
                        "submitparams":""
                      },
                      "columns":[
                        {
                          "MIGX_id":1,
                          "header":"ID",
                          "dataIndex":"id",
                          "width":"",
                          "sortable":"false",
                          "show_in_grid":"0",
                          "renderer":"",
                          "clickaction":"",
                          "selectorconfig":"",
                          "renderchunktpl":"",
                          "renderoptions":"[]"
                        },
                        {
                          "MIGX_id":2,
                          "header":"Product No",
                          "dataIndex":"prodno",
                          "width":150,
                          "sortable":true,
                          "show_in_grid":1,
                          "renderer":"",
                          "clickaction":"",
                          "selectorconfig":"",
                          "renderchunktpl":"",
                          "renderoptions":"[]"
                        },
                        {
                          "MIGX_id":3,
                          "header":"Name",
                          "dataIndex":"prodname",
                          "width":"",
                          "sortable":true,
                          "show_in_grid":1,
                          "renderer":"",
                          "clickaction":"",
                          "selectorconfig":"",
                          "renderchunktpl":"",
                          "renderoptions":"[]"
                        }
                      ]
                    }

                    and the configs for the productspecs config
                    {
                      "formtabs":[
                        {
                          "MIGX_id":1,
                          "caption":"Add Specification",
                          "print_before_tabs":"0",
                          "fields":[
                            {
                              "MIGX_id":1,
                              "field":"specifications.name",
                              "caption":"Name",
                              "description":"",
                              "description_is_code":"0",
                              "inputTV":"",
                              "inputTVtype":"text",
                              "configs":"",
                              "sourceFrom":"config",
                              "sources":"[]",
                              "inputOptionValues":"",
                              "default":""
                            },
                            {
                              "MIGX_id":2,
                              "field":"specifications.value",
                              "caption":"Value",
                              "description":"",
                              "description_is_code":"0",
                              "inputTV":"",
                              "inputTVtype":"text",
                              "configs":"",
                              "sourceFrom":"config",
                              "sources":"[]",
                              "inputOptionValues":"",
                              "default":""
                            }
                          ]
                        }
                      ],
                      "contextmenus":"update||duplicate||recall_remove_delete",
                      "actionbuttons":"addItem",
                      "columnbuttons":"",
                      "filters":"[]",
                      "extended":{
                        "migx_add":"",
                        "formcaption":"",
                        "update_win_title":"",
                        "win_id":"productspecs",
                        "maxRecords":"",
                        "addNewItemAt":"bottom",
                        "multiple_formtabs":"",
                        "extrahandlers":"",
                        "packageName":"productcatalog",
                        "classname":"Catalog",
                        "task":"",
                        "getlistsort":"",
                        "getlistsortdir":"",
                        "use_custom_prefix":"0",
                        "prefix":"",
                        "grid":"",
                        "gridload_mode":2,
                        "check_resid":1,
                        "check_resid_TV":"",
                        "join_alias":"",
                        "has_jointable":"yes",
                        "getlistwhere":"",
                        "joins":"",
                        "cmpmaincaption":"",
                        "cmptabcaption":"",
                        "cmptabdescription":"",
                        "cmptabcontroller":"",
                        "winbuttons":"",
                        "onsubmitsuccess":"",
                        "submitparams":""
                      },
                      "columns":[
                        {
                          "MIGX_id":1,
                          "header":"Name",
                          "dataIndex":"specifications.name",
                          "width":"",
                          "sortable":true,
                          "show_in_grid":1,
                          "renderer":"",
                          "clickaction":"",
                          "selectorconfig":"",
                          "renderchunktpl":"",
                          "renderoptions":"[]"
                        },
                        {
                          "MIGX_id":2,
                          "header":"Value",
                          "dataIndex":"specifications.value",
                          "width":"",
                          "sortable":true,
                          "show_in_grid":1,
                          "renderer":"",
                          "clickaction":"",
                          "selectorconfig":"",
                          "renderchunktpl":"",
                          "renderoptions":"[]"
                        }
                      ]
                    }


                    (Disregard the ProductImages reference... I have that part working since ProductImages is a separate table/Class)

                    My intended result from an update action is to have the currently loaded record ("product") have its specifications field updated with a JSON string. When I do the record update, it creates a new entry with everything blank EXCEPT the specifications field (which is populated as expected).

                    What piece of config am I missing?
                      • 4172
                      • 5,888 Posts
                      since you want to store the items as a json-string into the same table you will need a inputTVtype of 'migx' not 'migxdb' migxdb is trying to save its items into a table, each item, one db-record
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!