We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24676
    • 60 Posts
    Hi

    I am having a bit of a problem with rendering out a tick or cross switch and am a little out of my depth.

    I have a many to many relationship and Bruno very kindly helped my out tons a couple of months back where he showed my how to use a custom processor to make the joins.

    http://forums.modx.com/thread/?thread=90890&page=2

    This worked perfectly but I have since added some more relationships to my schema and I basically wanted to duplicate nesting my many to many relationships in migx.

    my schema now looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <model package="products" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
    <object class="ProductInfo" table="product_infos" extends="xPDOSimpleObject">
        <field key="name" dbtype="varchar" precision="100" phptype="string" null="false" default="" index="index" />
        <field key="chemicaldescription" dbtype="varchar" precision="250" phptype="string" null="false" default="" index="index" />
        <field key="shortdescription" dbtype="text" phptype="string" null="false" default="" index="index" />
        <field key="longdescription" dbtype="text" phptype="string" null="false" default="" index="index" />
        <field key="uselevel" dbtype="varchar" precision="250" phptype="string" null="false" default="" index="index" />
        <field key="ecocert" dbtype="int" precision="10" phptype="integer" null="false" default="0" index="index" />  
        <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
                    <column key="id" collation="A" null="false" />
            </index>
        <composite alias="ProductsApplication" class="ProductApplication" local="id" foreign="product" cardinality="many" owner="local" />
        <composite alias="ProductsFunction" class="ProductFunction" local="id" foreign="function" cardinality="many" owner="local" />
        <composite alias="ProductsSupplier" class="ProductSupplier" local="id" foreign="suppplier" cardinality="many" owner="local" />  
    </object>
    
    <object class="Application" table="applications" extends="xPDOSimpleObject">
        <field key="application" dbtype="varchar" precision="100" phptype="string" null="false" default="" index="index" />
        <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
            <column key="id" collation="A" null="false" />
        </index>
        <composite alias="ProductsApplication" class="ProductApplication" local="id" foreign="application" cardinality="many" owner="local" />
     </object>
    
     <object class="FunctionInfo" table="functions" extends="xPDOSimpleObject">
        <field key="function" dbtype="varchar" precision="100" phptype="string" null="false" default="" index="index" />
        <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
            <column key="id" collation="A" null="false" />
        </index>
        <composite alias="ProductsFunction" class="ProductFunction" local="id" foreign="function" cardinality="many" owner="local" />
    </object>
    
    <object class="ProductApplication" table="product_applications" extends="xPDOSimpleObject">
        <field key="product" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" index="index" />
        <field key="application" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" index="index" />
        <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
            <column key="id" collation="A" null="false" />
        </index>
        <aggregate alias="Product" class="ProductInfo" local="product" foreign="id" cardinality="one" owner="foreign" />
        <aggregate alias="Application" class="Application" local="application" foreign="id" cardinality="one" owner="foreign" />
    </object>
    
    <object class="ProductFunction" table="product_functions" extends="xPDOSimpleObject">
        <field key="product" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" index="index" />
        <field key="function" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" index="index" />
        <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
            <column key="id" collation="A" null="false" />
        </index>
        <aggregate alias="Product" class="ProductInfo" local="product" foreign="id" cardinality="one" owner="foreign" />
        <aggregate alias="Function" class="FunctionInfo" local="function" foreign="id" cardinality="one" owner="foreign" />
    </object>
    
    
    <object class="Supplier" table="suppliers" extends="xPDOSimpleObject">
        <field key="name" dbtype="varchar" precision="100" phptype="string" null="false" default="" index="index" />
        <field key="info" dbtype="text" phptype="string" null="false" default="" index="index" />
        <field key="logo" dbtype="varchar" precision="100" phptype="string" null="false" default="" index="index" />
        <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
            <column key="id" collation="A" null="false" />
        </index>
            <composite alias="SuppliersProducts" class="ProductSupplier" local="id" foreign="supplier" cardinality="many" owner="local" />
     </object>
    
     
     <object class="ProductSupplier" table="product_suppliers" extends="xPDOSimpleObject">
        <field key="product" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" index="index" />
        <field key="supplier" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" index="index" />
        <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
            <column key="id" collation="A" null="false" />
        </index>
        <aggregate alias="Product" class="ProductInfo" local="product" foreign="id" cardinality="one" owner="foreign" />
        <aggregate alias="Function" class="FunctionInfo" local="function" foreign="id" cardinality="one" owner="foreign" />
    </object>
     
    
    
    </model>


    Thanks to Brunos help in the post referenced about applications is working fine.

    I duplicated everything for functions and referenced these reusable processors. Although I have part success (i can pull in the functions and add new ones) The switch isn't working (tick/cross). ( see screenshot).

    When I viewed the source i can see:

    <img class="controlBtn undefined this.handleColumnSwitch Joined_active" src="/aston/undefined" alt="" title="">
    


    Which clearly isn't right. I have gone through the settings a hundred times and I can't see anything wrong, but I am sure it must be something fairly simple.

    The only thing I can add is I am getting the following in the error log, but I am not sure if it is related.

    [2014-07-26 00:32:26] (ERROR @ /aston/assets/components/migx/connector.php) No foreign key definition for parentClass: FunctionInfo using relation alias: {"classname":"ProductFuntion","local":"product","foreign":"function"}

    Advanced thanks!

    This question has been answered by rebornmedia. See the first response.

      • 4172
      • 5,888 Posts
      parentClass: FunctionInfo using relation alias: {"classname":"ProductFuntion","local":"product","foreign":"function"}
      


      did you parse the schema again after fixing the typo
      ProductFuntion to ProductFunction
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
      • discuss.answer
        • 24676
        • 60 Posts
        Bruno you are a legend....didn't see that typo - fixed it and parsed the schema again and hey presto!

        Feel a little bit stupid now - but at least it is working!

        Thank you so much!