Is here anyone who can write me step by step how to create dynamic drop down list with MIGX? What I need is a list of Regions, List of Districts depending on chosen Region and a list of Towns & Villages depending on Chosen District. It is supposed to contain about 3000 towns and villages for all districts so the best way would be to place them in txt file as comma separated list or something.
Thanks
are you talking about having this three dropdowns in the MIGX - window - form?
then you can try the dddx - TV.
Create a xpdo-schema with three custom - tables for Regions,Districts, and towns with proper defined relations
and create your processors for your dddx-group. for examples see
https://github.com/Bruno17/dddx/tree/master/core/components/dddx/processors/mgr/gallery_albums
your schema could be as simple as this:
<?xml version="1.0" encoding="UTF-8"?>
<model package="townsselector" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
<object class="tsRegion" table="ts_regions" extends="xPDOSimpleObject">
<field key="region" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<aggregate alias="Districts" class="tsDistrict" foreign="region_id" local="id" cardinality="many" owner="local"/>
</object>
<object class="tsDistrict" table="ts_districts" extends="xPDOSimpleObject">
<field key="district" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="region_id" dbtype="int" precision="11" phptype="integer" null="false" default="0" index="index" />
<aggregate alias="Region" class="tsRegion" local="region_id" foreign="id" cardinality="one" owner="foreign"/>
<aggregate alias="Towns" class="tsTown" foreign="district_id" local="id" cardinality="many" owner="local"/>
</object>
<object class="tsTown" table="ts_towns" extends="xPDOSimpleObject">
<field key="town" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
<field key="district_id" dbtype="int" precision="11" phptype="integer" null="false" default="0" index="index" />
<aggregate alias="District" class="tsDistrict" local="district_id" foreign="id" cardinality="one" owner="foreign"/>
</object>
</model>
this step shows, how to create your package with help of MIGXdb:
http://rtfm.modx.com/display/ADDON/MIGXdb.Create+doodles+manager+with+help+of+MIGXdb#MIGXdb.CreatedoodlesmanagerwithhelpofMIGXdb-CreateanewPackageandschemafile
replace 'doodles' with 'townsselector' for your packagename
[ed. note: Bruno17 last edited this post 14 years ago.]
I followed everything as in MIGXdb tutorial above but something goes wrong. Folder and tables were created properly but it displays "undefined" in Components->MIGX->townsselector and I found following errors in error log.
[2012-10-10 18:23:04] (ERROR @ /assets/components/migx/connector.php) addPackage called with an invalid package name.
[2012-10-10 18:23:04] (ERROR @ /assets/components/migx/connector.php) No class specified for loadClass
[2012-10-10 18:23:04] (ERROR @ /assets/components/migx/connector.php) No class specified for loadClass
[2012-10-10 18:23:04] (ERROR @ /assets/components/migx/connector.php) ::getSelectColumns() is not a valid static method.
[2012-10-10 18:23:04] (ERROR @ /assets/components/migx/connector.php) No class specified for loadClass
[2012-10-10 18:23:04] (ERROR @ /assets/components/migx/connector.php) No class specified for loadClass
[2012-10-10 18:23:04] (ERROR @ /assets/components/migx/connector.php) Could not load class
[2012-10-10 18:23:04] (ERROR @ /assets/components/migx/connector.php) No class specified for loadClass
[2012-10-10 18:23:04] (ERROR @ /assets/components/migx/connector.php) ::loadCollection() is not a valid static method.
If the classes and tables are created, all should be fine so far. The other stuff is only needed, when you want to edit this table(s) from a CMP.
You will need now to add some test-content into this tables and add the relation - ids. This can be done for example by phpmyadmin.
You will also need to install the dddx-package from github.
Then you are ready to create your dropdowns. Will explain it later, when you have done it so far.
I tried to open dddx-1.1.0-pl.transport.zip but it looks that archive is corrupted as I am unable to open it with any program even with default Win7 explorer. And by the way I really appreciate your help. Let me know if I can be of any help to you. Is it possible to add more fields to towns table and generate it as TVs let's say population, area, field for storing image name of coat of arms and similar data?
try to download it from here:
https://github.com/Bruno17/dddx/downloads
copy it to your packages folder
go to your package-management -> search locally for new packages
install the package
Of course, you can add as many fields to your table as you want and can manage the records by MIGXdb
you will need first to modify the db-schema, then create the tables.
its also possible to add new fields to an existing table, by adding new fields to the schema.
then adding the new fields to the table and map-files with help of the MIGX-packagemanager by just one (or two) mouseclicks
[ed. note: Bruno17 last edited this post 14 years ago.]
OK that one worked perfect. I have added sample data to all tables and installed dddx. So what are the next steps?
now you can create your three dddx-TVs
name: tsRegion
input type: dynamic_dropdown
dddx Group: townsselector
first row text: -- choose Region --
packagename: townsselector
classname: tsRegion
idfield: id
namefield: region
name: tsDistrict
input type: dynamic_dropdown
Parent Dropdown: tsRegion
dddx Group: townsselector
first row text: -- choose District --
packagename: townsselector
classname: tsDistrict
idfield: id
namefield: district
name: tsTown
input type: dynamic_dropdown
Parent Dropdown: tsDistrict
dddx Group: townsselector
first row text: -- choose Town --
packagename: townsselector
classname: tsTown
idfield: town
namefield: town