On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Hi,

    I'm trying to make a "media list" with MIGXdb.
    Every media item can have an other list. A list of images (for a gallery).

    So my thought is this:

    MIGXdb 1: mediaList
    - title
    - description
    - media <-- this one shoud be connected to an other MIGXdb
    - buttonText
    - buttonURL

    MIGXdb 2: media

    Thats the basic idea. Of course there should (?) be more fields like id, published on, and so on...

    Is this possible? Using "aggregate" in the schema? Or maybe "joins" in the configuration? How would I do this?

    Thank you.

    • This is possible, I need this very often.

      what you would need is a relation between this two tables.

      for example in your schema for media you would need this:

      <field key="medialist_id" dbtype="int" precision="11" phptype="integer" null="false" default="0" />

      <aggregate alias="MedialistItem" class="yourMedialistClassname" local="medialist_id" foreign="id" cardinality="one" owner="foreign" />

      then you can have in your media-configuration on the tab MIGXdb Settings:

      Check Resouce: Yes (in this case its not a resource but a record of your connected table to check for connection)

      Join Alias: MedialistItem

      this should be it.

      the default-update-processor should automatically fill the medialist_id - value when you save a new record and the default-getlist-processor should filter them in the grid, which are connected to the medialist-record.

        you can buy me a beer, if you like MIGX


      • Alright! Looks very intuitive. Thank you for your time to explain this Bruno.

        How would I create this migx-field in mediaList?
        (To make the media-migx show up in the mediaList-migx) [ed. note: Eminos last edited this post 6 years, 10 months ago.]
        • create a new field
          name: doesn't matter
          input TV type: migxdb
          configs: theMediaConfig (configuration for the Media-grid)

            you can buy me a beer, if you like MIGX


          • Do I also need a field for "media" in the mediaList schema, or is that taken care of automatically?
            • I just tried to do this, and it kinda works smiley

              The only thing I'm missing is that when I add a new media file to "media" it doesn't show up in the media grid.

              Both databases seem to be working fine, I can se the media list items beeing added to the medialist database, and also the media files in the media database (with the correct medialist_id).

              I added the two columns (title and file) to the media configuration, but when I add a new file it just makes the animation and still says "No items found" in the grid.
              • what do you get (the response, you can check this with firebug) when uncommenting this line in the

                migx - default/getlist.php processor:

                //$c->prepare();echo $c->toSql();


                $c->prepare();echo $c->toSql();

                when you click the 'show grid' button


                  you can buy me a beer, if you like MIGX


                • I commented that line out in this file:
                  That must the file you're refering to.

                  When I do that I cant even load the first mediaList MIGXdb TV in the resource.
                  The grid shows up empty and I get this in the firebug console:

                  SyntaxError: illegal character
                  Line 7
                  (SELECT `mediaList`.`id`, `mediaList`.`title`, `mediaList`.`description`, `media...

                  The illegal character points at the first ` character.
                  • do it in this order:

                    1. open the resource-editor
                    2. open the mediaList - grid
                    3. click the 'add item' - button to open the formwindow.

                    4. uncomment this line in the getlist.php - file

                    5. load the grid

                    6. let me know this part completly:
                    SELECT ..............


                      you can buy me a beer, if you like MIGX


                    • Ok.
                      I open the resource editor.
                      Open Firebug.
                      Go to Template Variables tab.
                      Choose Media List category.
                      Click Load Grid.
                      Firebug gives that error and the grids shows up empty.

                      The screenshot I'm attaching is from this moment.

                      I can click the Add Item button to get the Add Item MIGX popup where I have that other media migxdb.
                      If I click on THAT Load Grid, I get the "Before adding new items, you need to save this Object!".
                      I can save the object, but it doesn't show up in the grid, and just spits out yet an other error, same as before (see screenshot).

                      Keep in mind I only get those error with that line of yours not commented out. If it's commented out it all seems fine except that first problem with "media migxdb" grid not showing any items.