We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7557
    • 61 Posts
    Hi!
    I created a table of products and the scheme for it.
    <object class="Products" table="products" extends="xPDOSimpleObject">
    <aggregate alias="Resource" class="modResource" local="resource" foreign="id"  cardinality="one" owner="foreign" />
    <field key="resource" dbtype="int" precision="11" phptype="integer" null="false" index="index" />
    etc..
    </object>

    I want to delete product when deleting a resource from aggregate relationships.
    How and where to extend or add composite relationships in modResource class.
    Is it possible, and whether this is the correct procedure?
    thx.
      • 24013
      • 7 Posts
      I’ve got a similar need. Is this possible??

      	<object class="Eventcomps" table="eventcomps" extends="xPDOObject">
      		<field key="id_comp" dbtype="int" precision="9" phptype="integer" null="false" index="pk"  generated="native" />
      		<field key="compid_comp" dbtype="int" precision="11" phptype="integer" null="true" />
      		<field key="eid_comp" dbtype="int" precision="9" phptype="integer" null="false" index="index" />
                      <aggregate alias="Resource" class="modResource" local="eid_comp" foreign="id" cardinality="one" owner="foreign" />
      	</object>
      
        44+ MODXed sites and counting...
        • 18373 ☆ A M B ☆
        • 3,141 Posts
        Yes; you can extend modResource.

        No; I’ve never done it or things to think about and as it’s such a vital part of what’s going on in the Manager I sort of didn’t try it tongue All I know is that there’s a system setting called "custom_resource_classes" and that I’m pretty sure you’ll need to add your custom class there, I’m guessing in JSON format which specifies the model path and class name at least.

        I *think* you’ll end up having to create your own new/update controllers when using a custom modResource class in which I would personally go for the simple solution: hook a plugin into on(Before)DocFormDelete / onEmptyTrash and do some logic checking in that.
          Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

          Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.