... {toc} h2. Creating a doodles-manager with help of MIGXdb In this Tutorial we will learn how to create a doodles-manager with help of MIGXdb. The result at the end will be somelike the same as its done here, but without doing one line of coding: [Developing an Extra in MODX Revolution|revolution20:Developing an Extra in MODX Revolution] First we will create a db-schema and its table(s), if not allready done. Then we will create and configure a MIGXdb-CMP to manage our doodles (db-records). h2. Requirements First off we will need to install [MIGX|ADDON:MIGX] by package-management and do some [basic configurations|MIGXdb.Configuration]. h2. Create a new Package and schema-file Go to Components->MIGX->Tab 'Package Manager' add a name for your new package into the field 'packageName:'. For our example we use 'doodles'. Click 'Create Package' This should create a directory under your core-path with an empty schema-file in its correct place. Still having 'doodles' in the field packageName we want to fill the textarea-field 'schema'. Go to the tab 'xml schema' and add this code: h3. The Schema {code:xml} <?xml version="1.0" encoding="UTF-8"?> <model package="doodles" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM"> <object class="Doodle" table="doodles" extends="xPDOSimpleObject"> <field key="name" dbtype="varchar" precision="255" phptype="string" null="false" default=""/> <field key="description" dbtype="text" phptype="string" null="false" default=""/> <field key="createdon" dbtype="datetime" phptype="datetime" null="true"/> <field key="createdby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" /> <field key="editedon" dbtype="datetime" phptype="datetime" null="true"/> <field key="editedby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" /> <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="0" /> <aggregate alias="CreatedBy" class="modUser" local="createdby" foreign="id" cardinality="one" owner="foreign"/> <aggregate alias="EditedBy" class="modUser" local="editedby" foreign="id" cardinality="one" owner="foreign"/> </object> </model> {code} by clicking 'Save Schema' we should have our schema-file created. You can test it by clicking 'Load Schema' {note} I've added two fields to the original doodles-schema: published, deleted This fields are required by the default getlist-processor of MIGXdb. If you had allready created the doodles-table you can add this fields to your existing schema and go to the tab 'add fields' to add the new fields to your map and table. Of course you can create your own processors under your own processor-path. {note} h3. Parse Schema Create xpdo-classes and maps from schema by clicking 'Parse Schema' on the tab 'Parse Schema' h3. Create Table(s) Create tables from schema by clicking 'Create Tables' on the tab 'Create Tables' This schould create our table. h2. Create the Configuration Now we want to create our configuration for the MIGXdb-CMP. Go to the main-tab 'MIGX' There should be an grid with some buttons. We click the 'Add item' - button In the opening window we add: h3.Settings Name: doodles - this is the name of our configuration. Make sure to use unique configuration-names. "Add Item" Replacement: Add Doodle - this is the text on our 'Add Item' - Button
|
... Header: ID field: id Header: Name field: name Header: Description field: description h3. Formtabs click 'add item' to add a new formtab Caption: Doodle We add two fields to our tab: click 'add item' fieldname: name Caption: Name fieldname: description Caption: Desription inputTVtype: textarea h3. MIGXdb-Settings package: doodles classname: Doodle h3.db-filters click 'add item' filter name: search filter type: textbox getlist where: {code}{"name:LIKE":"%[[+search]]%","OR:description:LIKE":"%[[+search]]%"}{code} h3.Contextmenues check: update h3.Actionbuttons check: add item h2. Create a menu to your CMP System -> Actions menu-tree: Components->MIGX->right-click->Place Action here Lexicon-key: doodles Action: migx-index parameters &configs=doodles click 'save' h2. Done refresh the manager go to Components->MIGX->doodles There is it, your new doodles-manager!
|