We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Learned a lot reading this post entirely.
    MIGx is such an awesome contribution.
    Looking forward for some bloX documentation!

    Just finished creating my first package files complete with schemas, tables, relationships between objects, migx tvs, cmps, and custom forms, tvs with @EVAL return runSnippet() and custom Snippets.

    MIGx is like a guided tour trough all the possibilities inside modX.

    Thank you again, Bruno.

    • I'm getting the same error when trying to remove an item right-clicking the item on the grid.

      quip.thread_err_ns


      All my Objects / tables have an 'id' column as primary key.
      When i use Write Schema and load the created shema file the 'id' field from the table is not present, why?

      <?xml version="1.0" encoding="UTF-8"?>
      <model package="cartelera" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
      	<object class="Cartelera" table="cartelera" extends="xPDOSimpleObject">
      		<field key="name" dbtype="varchar" precision="255" phptype="string" null="false" />
      		<field key="startdate" dbtype="datetime" phptype="datetime" null="false" />
      		<field key="enddate" dbtype="datetime" phptype="datetime" null="false" />
      		<field key="deleted" dbtype="tinyint" precision="1" phptype="integer" null="false" />
      		<field key="published" dbtype="tinyint" precision="1" phptype="integer" null="false" />
      	</object>
      </model>
      


      [ed. note: lithiumlab last edited this post 11 years, 6 months ago.]
        • 4172
        • 5,888 Posts
        do you have the field 'id' in your columns (can be hidden from grid, but must be defined)

        extends="xPDOSimpleObject">


        says xpdo, there is a primary-key-field with name 'id'
        no field-definition needed for this field.
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
        • Ahj!
          Understood. Problem solved.

          Deleted all the project tables and recreated it using the schema and everything is ok now.
            • 41349
            • 10 Posts
            Hi
            When i trying to delete or publish/unpublish row is nothing happens or im getting error
            quip.comment_err_remove

            My schema:
            <?xml version="1.0" encoding="UTF-8"?>
            <model package="rssfeeds" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
                <object class="Rssfeed" table="rssfeeds" extends="xPDOSimpleObject">
                    <field key="link" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                    <field key="title" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                    <field key="small" dbtype="text" phptype="string" null="false" default=""/>
                    <field key="createdon" dbtype="datetime" phptype="datetime" null="true"/>
                    <field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />  
                    <field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
                </object>
            </model>

            Table contains rss feeds and editor publish or delete them.
            Configuration created with help of "Create doodles manager" tutorial.
              • 40045
              • 534 Posts
              Quote from: lithiumlab at Oct 30, 2012, 09:28 AM
              I'm getting the same error when trying to remove an item right-clicking the item on the grid.

              quip.thread_err_ns


              All my Objects / tables have an 'id' column as primary key.
              When i use Write Schema and load the created shema file the 'id' field from the table is not present, why?

              <!--?xml version="1.0" encoding="UTF-8"?-->
              <model package="cartelera" baseclass="xPDOObject" platform="mysql" defaultengine="MyISAM" version="1.1">
              	<object class="Cartelera" table="cartelera" extends="xPDOSimpleObject">
              		<field key="name" dbtype="varchar" precision="255" phptype="string" null="false">
              		<field key="startdate" dbtype="datetime" phptype="datetime" null="false">
              		<field key="enddate" dbtype="datetime" phptype="datetime" null="false">
              		<field key="deleted" dbtype="tinyint" precision="1" phptype="integer" null="false">
              		<field key="published" dbtype="tinyint" precision="1" phptype="integer" null="false">
              	</field></field></field></field></field></object>
              </model>
              




              just had exactly the same error, it just happens when using the contextmenu/rightclick "remove" feature, when using the rowAction "remove" (with the button, displayed under a row field), it works...

              EDIT: as bruno already wrote, if you add a hidden from the grid field "id" to the inner migxdb columns (in the configurator, additionally to the itemid field that identifies the item from the other table), also the right click "remove" works!
                • 24414
                • 45 Posts
                Haha! Breakthrough!

                I can now add items to the child table with [virtually] no errors!

                So it seems where I was going wrong was in adding the whole child config from "Export/Import" to the parent MIGXdb TV config input. Instead I should have just added its name! Oops!

                Issues I still have—

                An error in the log:
                (ERROR @ /assets/components/migx/connector.php) No foreign key definition for parentClass: xportfolio using relation alias: Resource


                I can add items to the child but when I delete a parent item its child items stay in the DB. So how do I make the parent talk to the child table to remove them?

                Schema
                <?xml version="1.0" encoding="UTF-8"?>
                <model package="xportfolio" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
                
                    <object class="xportfolio" table="xportfolio" extends="xPDOSimpleObject">
                		
                		<field key="project" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                		<field key="client" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                		
                		<field key="tags" dbtype="text" phptype="string" null="false" default=""/>
                		<field key="desc" dbtype="text" phptype="string" null="false" default=""/>
                
                		<field key="img" dbtype="text" phptype="string" null="false" default=""/>
                		<field key="img_sml" dbtype="text" phptype="string" null="false" default=""/>
                
                		<field key="url" dbtype="text" phptype="string" null="false" default=""/>
                		<field key="url_text" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                		<field key="url_desc" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                		
                		<field key="promote" dbtype="tinyint" precision="1" phptype="integer" null="false" default="0"/>
                		
                		<field key="pos" dbtype="int" precision="10" phptype="integer" null="false" default="0"/>
                		
                		<field key="extended" dbtype="text" phptype="json" null="false" default=""/>
                
                		<field key="createdon" dbtype="datetime" phptype="datetime" null="true"/>
                		<field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0"/>
                        <field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="1"/>
                						
                		<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                			<column key="id" collation="A" null="false"/>
                		</index>
                
                    </object>
                	
                	<object class="xportfolio_gal" table="xportfolio_gal" extends="xPDOSimpleObject">
                		
                		<field key="gal_id" dbtype="int" precision="11" phptype="integer" null="true"/>
                	
                		<field key="gal_img_title" dbtype="text" phptype="string" null="false" default=""/>
                		<field key="gal_img_desc" dbtype="text" phptype="string" null="false" default=""/>
                
                		<field key="gal_img" dbtype="text" phptype="string" null="false" default=""/>
                		<field key="gal_img_sml" dbtype="text" phptype="string" null="false" default=""/>
                
                		<field key="pos" dbtype="int" precision="10" phptype="integer" null="false" default="0"/>
                
                		<field key="createdon" dbtype="datetime" phptype="datetime" null="true"/>
                		<field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0"/>
                        <field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="1"/>
                
                		<aggregate alias="xportfolio_projects" class="xportfolio" local="gal_id" foreign="id" cardinality="one" owner="foreign"/>
                
                		<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                			<column key="id" collation="A" null="false"/>
                		</index>
                
                	</object>
                
                </model>


                Config (Parent)
                {
                  "formtabs":[
                    {
                      "MIGX_id":1,
                      "caption":"Info",
                      "print_before_tabs":"0",
                      "fields":[
                        {
                          "MIGX_id":2,
                          "field":"project",
                          "caption":"Project",
                          "description":"",
                          "description_is_code":"0",
                          "inputTV":"",
                          "inputTVtype":"",
                          "configs":"",
                          "sourceFrom":"config",
                          "sources":"[]",
                          "inputOptionValues":"",
                          "default":""
                        },
                      {
                          "MIGX_id":1,
                          "field":"gallery",
                          "caption":"Gallery Images",
                          "description":"",
                          "description_is_code":"0",
                          "inputTV":"",
                          "inputTVtype":"migxdb",
                          "configs":"xportfolio_gal",
                          "sourceFrom":"config",
                          "sources":"[]",
                          "inputOptionValues":"",
                          "default":""
                        }
                      ]
                    }
                  ],
                  "contextmenus":"update||publish||unpublish||remove",
                  "actionbuttons":"addItem",
                  "columnbuttons":"",
                  "filters":"[]",
                  "extended":{
                    "migx_add":"Add Project",
                    "formcaption":"",
                    "update_win_title":"Portfolio",
                    "win_id":"xportfolio",
                    "maxRecords":"",
                    "multiple_formtabs":"",
                    "extrahandlers":"",
                    "packageName":"xportfolio",
                    "classname":"xportfolio",
                    "task":"",
                    "getlistsort":"",
                    "getlistsortdir":"",
                    "use_custom_prefix":"0",
                    "prefix":"",
                    "grid":"",
                    "gridload_mode":1,
                    "check_resid":"0",
                    "check_resid_TV":"",
                    "join_alias":"",
                    "getlistwhere":"",
                    "joins":"",
                    "cmpmaincaption":"",
                    "cmptabcaption":"",
                    "cmptabdescription":"",
                    "cmptabcontroller":"",
                    "winbuttons":"",
                    "onsubmitsuccess":"",
                    "submitparams":""
                  },
                  "columns":[
                    {
                      "MIGX_id":1,
                      "header":"ID",
                      "dataIndex":"id",
                      "width":"",
                      "sortable":"false",
                      "show_in_grid":1,
                      "renderer":"",
                      "clickaction":"",
                      "selectorconfig":"",
                      "renderoptions":"[]"
                    },
                    {
                      "MIGX_id":3,
                      "header":"Project",
                      "dataIndex":"project",
                      "width":"",
                      "sortable":"false",
                      "show_in_grid":1,
                      "renderer":"",
                      "clickaction":"",
                      "selectorconfig":"",
                      "renderoptions":"[]"
                    }
                  ]
                }


                Config (Child)
                {
                  "formtabs":[
                    {
                      "MIGX_id":1,
                      "caption":"Image",
                      "print_before_tabs":"0",
                      "fields":[
                        {
                          "MIGX_id":1,
                          "field":"gal_img_title",
                          "caption":"Title",
                          "description":"",
                          "description_is_code":"0",
                          "inputTV":"",
                          "inputTVtype":"",
                          "configs":"",
                          "sourceFrom":"config",
                          "sources":"[]",
                          "inputOptionValues":"",
                          "default":""
                        },
                        {
                          "MIGX_id":2,
                          "field":"gal_img_desc",
                          "caption":"Description",
                          "description":"",
                          "description_is_code":"0",
                          "inputTV":"",
                          "inputTVtype":"",
                          "configs":"",
                          "sourceFrom":"config",
                          "sources":"[]",
                          "inputOptionValues":"",
                          "default":""
                        },
                        {
                          "MIGX_id":3,
                          "field":"gal_img_sml",
                          "caption":"Image - Small",
                          "description":"",
                          "description_is_code":"0",
                          "inputTV":"",
                          "inputTVtype":"image",
                          "configs":"",
                          "sourceFrom":"config",
                          "sources":"[]",
                          "inputOptionValues":"",
                          "default":""
                        }
                      ]
                    }
                  ],
                  "contextmenus":"update||publish||unpublish||remove",
                  "actionbuttons":"addItem",
                  "columnbuttons":"",
                  "filters":"[]",
                  "extended":{
                    "migx_add":"Add an Image",
                    "formcaption":"",
                    "update_win_title":"Add Images",
                    "win_id":"xportfolio_gal",
                    "maxRecords":"",
                    "multiple_formtabs":"",
                    "extrahandlers":"",
                    "packageName":"xportfolio",
                    "classname":"xportfolio_gal",
                    "task":"",
                    "getlistsort":"",
                    "getlistsortdir":"",
                    "use_custom_prefix":"0",
                    "prefix":"",
                    "grid":"",
                    "gridload_mode":1,
                    "check_resid":1,
                    "check_resid_TV":"",
                    "join_alias":"xportfolio_projects",
                    "getlistwhere":"",
                    "joins":"",
                    "cmpmaincaption":"",
                    "cmptabcaption":"",
                    "cmptabdescription":"",
                    "cmptabcontroller":"",
                    "winbuttons":"",
                    "onsubmitsuccess":"",
                    "submitparams":""
                  },
                  "columns":[
                    {
                      "MIGX_id":1,
                      "header":"Gal ID",
                      "dataIndex":"gal_id",
                      "width":"",
                      "sortable":"false",
                      "show_in_grid":1,
                      "renderer":"",
                      "clickaction":"",
                      "selectorconfig":"",
                      "renderoptions":"[]"
                    },
                    {
                      "MIGX_id":2,
                      "header":"ID",
                      "dataIndex":"id",
                      "width":"",
                      "sortable":"false",
                      "show_in_grid":1,
                      "renderer":"",
                      "clickaction":"",
                      "selectorconfig":"",
                      "renderoptions":"[]"
                    },
                    {
                      "MIGX_id":3,
                      "header":"Title",
                      "dataIndex":"gal_img_title",
                      "width":"",
                      "sortable":"false",
                      "show_in_grid":1,
                      "renderer":"",
                      "clickaction":"",
                      "selectorconfig":"",
                      "renderoptions":"[]"
                    }
                  ]
                }
                [ed. note: ram last edited this post 10 years, 9 months ago.]
                  • 24414
                  • 45 Posts
                  Right—

                  Got the parent to delete some files from the child by adding a composite alias. Looking good. Got the "No foreign key definition for parentClass: xportfolio using relation alias: Resource" error to go away by adding the "resource_id" back to the parent again .

                  Found duplicate entries to the parent table when adding items to the child and fixed with the info in:

                  http://forums.modx.com/thread/84792/nested-migxdb-error-log and https://github.com/Bruno17/MIGX/issues/95#issuecomment-19496281

                  As noted not all items are being deleted from the child table. I can get one child item removed when I delete a parent item. So if I create:

                  Project A in the parent and add Images A1, A2, A3 to the child
                  Project B in the parent and add Images B1, B2 to the child

                  Then I delete Project A and Project B

                  I get left with Images A2, A3, B2 in the child table — only one item from each project deleted.

                  Lots of progress but I really don’t have a clue what I am doing!

                  My current schema:

                  <?xml version="1.0" encoding="UTF-8"?>
                  <model package="xportfolio" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
                  
                      <object class="xportfolio" table="xportfolio" extends="xPDOSimpleObject">
                  		
                  		<field key="resource_id" dbtype="int" precision="11" phptype="integer" null="false" default="0"/>
                  		
                  		<field key="project" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                  		<field key="client" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                  		
                  		<field key="tags" dbtype="text" phptype="string" null="false" default=""/>
                  		<field key="desc" dbtype="text" phptype="string" null="false" default=""/>
                  
                  		<field key="img" dbtype="text" phptype="string" null="false" default=""/>
                  		<field key="img_sml" dbtype="text" phptype="string" null="false" default=""/>
                  
                  		<field key="url" dbtype="text" phptype="string" null="false" default=""/>
                  		<field key="url_text" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                  		<field key="url_desc" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                  		
                  		<field key="promote" dbtype="tinyint" precision="1" phptype="integer" null="false" default="0"/>
                  		
                  		<field key="pos" dbtype="int" precision="10" phptype="integer" null="false" default="0"/>
                  		
                  		<field key="extended" dbtype="text" phptype="json" null="false" default=""/>
                  
                  		<field key="createdon" dbtype="datetime" phptype="datetime" null="true"/>
                  		<field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0"/>
                          <field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="1"/>
                  		
                  		<composite alias="xportfolio_gallery" class="xportfolio_gal" local="id" foreign="gal_id" cardinality="one" owner="local"/>
                  		<aggregate alias="Resource" class="modResource" local="resource_id" foreign="id" cardinality="one" owner="foreign"/>
                  
                      </object>
                  	
                  	<object class="xportfolio_gal" table="xportfolio_gal" extends="xPDOSimpleObject">
                  		
                  		<field key="gal_id" dbtype="int" precision="11" phptype="integer" null="true"/>
                  	
                  		<field key="gal_img_title" dbtype="text" phptype="string" null="false" default=""/>
                  		<field key="gal_img_desc" dbtype="text" phptype="string" null="false" default=""/>
                  
                  		<field key="gal_img" dbtype="text" phptype="string" null="false" default=""/>
                  		<field key="gal_img_sml" dbtype="text" phptype="string" null="false" default=""/>
                  
                  		<field key="pos" dbtype="int" precision="10" phptype="integer" null="false" default="0"/>
                  
                  		<field key="createdon" dbtype="datetime" phptype="datetime" null="true"/>
                  		<field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0"/>
                          <field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="1"/>
                  
                  		<aggregate alias="xportfolio_projects" class="xportfolio" local="gal_id" foreign="id" cardinality="one" owner="foreign"/>
                  
                  	</object>
                  
                  </model>
                  [ed. note: ram last edited this post 10 years, 9 months ago.]
                    • 4172
                    • 5,888 Posts
                    each project can have multiple images.
                    This is a one/many - relationship.
                    So you need cardinality: many

                    <composite alias="xportfolio_gallery" class="xportfolio_gal" local="id" foreign="gal_id" cardinality="many" owner="local"/>
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 24414
                      • 45 Posts
                      Aha! Wonderful! Thank you!

                      …and thank you for this wonderful tool!

                      Now to get my head around outputting data.

                      It has been quite a mission getting my head round it but it’s taught me a lot and encouraged me to do a lot more reading. I think I have done quite a few silly things along the way!

                      One thing I wonder though…

                      What is the significance of the "resource_id" field and the aggregate alias "Resource"? I look at the table and the value for "resource_id" is 0 for all rows I see.