Hi,
i have trouble setting up a new cmp page with modx 3. It always worked with modx 2 and an existing cmp does also work with modx 3. i just can’t create a new one.
i can create my schema, and i can also parse it. but when i want to create the tables i get a 500 error in the developer console on this url: https://www.rifflblech.com/assets/components/migx/connector.php. no additional details and also no output in modx’s error logs.
Problem is in Create Table. When I click the button: “Create Tables” nothing happens. But when I check the console in Chrome there is an error: /assets/components/migx/connector.php:1 Failed to load resource: the server responded with a status of 500 ()
If you want to be able to change the data of one of the existing core MODX database table in MIGX, you can set the “Classname” in the MIGX configuration (tab “MIGXdb-Settings”) to (for example) MODX\Revolution\modResource.
I want to be able to do editing of some custom tables that I added to the database.
For example:
I want to make a dictionary for basic words found on a website. I have added a table with 4 fields (id, en, fr, de) to the database and need to be able to edit this table.
Sample record:
id: 1
en: more
fr: plus
de: mehr
CREATE TABLE `dictionary` (
`id` int(11) NOT NULL,
`en` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`fr` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
`de` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO `dictionary` (`id`, `en`, `fr`, `de`) VALUES
(1, 'more', 'plus', 'mehr');
It’s usually better to start with the schema, than to create the custom table manually.
In MIGX there is a way to create a schema from existing database tables, by using the “Write schema” button in the “Package Manager”. But you probably need a custom table prefix for it to work properly (and there is still a bug in MIGX for custom table prefixes in MODX 3).
Also, the table you created misses a proper (autoincrement) primary key.
If I was you, I would create a new package in MIGX with the name “Mycompany”.
Then use a schema like this:
Here is an example if you want to create the database table first:
Create the table in SQL with a custom prefix (here myprefix_)
CREATE TABLE `myprefix_dictionary` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`en` varchar(100) NOT NULL DEFAULT '',
`fr` varchar(100) NOT NULL DEFAULT '',
`de` varchar(100) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB CHARSET=utf8mb4;
In the MIGX “Package Manager” set “Package Name:” to Mypackage, “table-prefix:” to Custom Prefix and “custom-prefix:” to myprefix_. Click the button “Create Package”.
Click the button “Write schema” (tab “Schema”).
Check if the schema was created correctly. Go to the tab “Xml Schema” and click the button “Load schema” (or open the file core/components/mypackage/schema/mypackage.mysql.schema.xml). The schema should look like this:
Change the bootstrap file: Open the file core/components/mypackage/bootstrap.php and make sure the addPackage function looks like this (with the custom prefix as the third parameter).
I am writing a simple snippet to extract data from this table but I keep getting an error. I wanted to fetch, for example, the record “id=1” and output the column “en”
One more problem. I can add new items, I can delete but when I want to edit it opens a window and all the fields are empty. I have selected “update” in “Contextmenues” is there still something extra to set?