We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41592 ☆ A M B ☆
    • 83 Posts
    Hello everyone!
    I'm here because I'm trying to extend the modResource Class and manage their extra field.
    I looked at the guide to "extend modUser" and "create Resource Class".
    http://rtfm.modx.com/display/revolution20/Creating+a+Resource+Class
    http://rtfm.modx.com/display/revolution20/Extending+modUser

    I created two new CRC called "Resort" and "Room", for each of them I created controllers and processors:
    class Room extends modResource{...}
    class Resort extends modResource{...}
    class RoomCreateProcessor extends modResourceCreateProcessor {...}
    class RoomUpdateProcessor extends modResourceUpdateProcessor {...}
    class ResortCreateManagerController extends ResourceCreateManagerController{...}
    class RoomCreateManagerController extends ResourceCreateManagerController{...}


    and everythings it's fine and work! I can create different resource, like Resort and Room.
    Now I would like to extend the resource "Room" following the logic of "ExtUser", so I created the following schema:

    <model package="swingtime" version="1.0" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM">
        <object class="Resort" extends="modResource" />
    	<object class="Room" extends="modResource" >
    		<composite alias="roomInfo" class="roomInfo" local="id" foreign="roomInfo_id" cardinality="one" owner="local" />	
    	</object>
    	<object class="RoomContainer" extends="modResource" />
    		
    	<object class="roomInfo" table="roominfo" extends='xPDOSimpleObject'>
        	<field key='roomInfo_id' dbtype='int' precision='10' phptype='integer' null='false' />
    		<field key='name' dbtype='varchar' precision='255' phptype='string' null='false'/>
    		<field key='description' dbtype='varchar' precision='525' phptype='string' null='false'/>
    		<field key='img' dbtype='varchar' precision='255' phptype='string' null='true'/>
    		<index alias="roomInfo_id" name="roomInfo_id" primary="false" unique="true" type="BTREE">
            	<column key="roomInfo_id" collation="A" null="false" />
        	</index>
    			<aggregate alias='Room' local='roomInfo_id' foreign='id' cardinality='one' owner='foreign' />
        </object>
    </model>


    Now my questions are:
    1) How do I handle fields of roomInfo through RoomCreateProcessor and RoomUpdate Processor?
    2) it is possible to manage the fields directly in the panel for creating a new "Room" by adding their fields in the panel Ext.extend(Swingtime.panel.Room) during creation or updating? How?

    Thx in advice!

    Waiting for reply tongue
      Francesco Mussoni | MODX Ambassador | Skype: solidusite2 | Email: [email protected]
      • 9207 ☆ A M B ☆
      • 2,475 Posts
      I'm trying to do something very similar -- did you ever figure out how to add fields (and tabs) to the panel during create/update of the Room/Resort resources?
        • 41592 ☆ A M B ☆
        • 83 Posts
        yes of course, I will make a tutorial on how to. By the way you can find some guideline on this post:

        https://forums.modx.com/thread/86374/custom-resource-class-with-related-data-question-s#dis-post-478635
          Francesco Mussoni | MODX Ambassador | Skype: solidusite2 | Email: [email protected]