How do I import data from Excel to getImageList?

Hi. Tell me, what are the options for importing data from Excel to getImageList?

getImageList is the snippet to output MIGX data to the front-end.

To import data for MIGX, there exists an action-button “importcsvmigx”.
In the MIGX configuration, go to the tab “Actionbuttons” and select the checkbox “importcsvmigx”.

Save you Excel data as a CSV (comma-separated values) file, so it can be imported.

Hello. In migx, I don’t see any configurations created.


The page template has

 [[!getImageList? 
                                &tvname=`price_category_2`
                                &tpl=`price_choise`
                                &docid=`[[*id]]`
                             ]]

TV price_category_2

You defined your MIGX TV directly in the TV (fields “Form Tabs” and “Grid Columns” in the tab “Input Options”).
I don’t think you can add the “Import”-Button this way.

Define the MIGX fields and columns by creating a new MIGX configuration (menu “Extras” → “MIGX”). Then in your TV, use the field “Configurations” to reference the created configuration (instead of using the fields “Form Tabs” and “Grid Columns”).

good afternoon. thanks

I’m trying to import some csv data into MIGX. There seems to be no tutorial, step by step on this, but I did finally find this topic. I think I’m pretty close but it’s not yet working.

I want to create a very simple glossary with just two fields, “Term” and “Definition”. I’ve created a configuration called “glossary” where I’ve set up the formtabs and columns. I’ve also added a action button called importcsvmigx. I’ve left all other fields blank.

I’ve created a MIGX tv where I’ve specified the “glossary” configuation in lieu of the formtabs and grid columns directly in the tv.

I’ve manually added a couple of terms and definitions on the resource where I’ve assigned the MIGX tv so I know the tv configuration is working. The import csv button is available and when I click on it I can navigate to the csv file.

The csv file has the field names in the first row of the file and two rows of data.

When I select the file and click OK. Nothing happens. I feel like I’m really close on this, but clearly missing something.

Any suggestions?

When I test it, there is an error ... fopen(glossary.csv): failed to open stream: No such file or directory in the MODX error log (and lots of subsequent errors).

It helps (in my case) when I change the import processor here

to add the MODX base path to the (relative) CSV file path:

$result = parse_csv_file(MODX_BASE_PATH . $pathname, $config);

Brilliant! That did the trick.

Thank you so much.

Is that something that needs to be patched?

It looks like the same code works correctly on MODX 2.x (but creates the error on MODX 3).

I have to take a closer look at the code to see why.
If I find a solution that works for both MODX 2 and 3, I will create a PR on Github.

That would be great. Thank you!

I created a pull request with a solution that is a bit different.

The quick fix I posted above only works, if the CSV file is selected in the default “Filesystem” media source.

Excellent! Thank you.

After this is implemented and I upgrade MIGX, will this will replace the “fix” you gave me earlier?

Hello. Could you please describe in more detail how to import data from csv to a table. I have created a configuration, but when I load the csv, the rows appear in the table, but there are no values.

Can you provide more information about your setup:

  • How does your CSV file look? Does the first line contain the names of the columns?
  • What’s your MIGX configuration file? (You can export it by right-clicking on the config → “Export/Import” → and copying the JSON from the field.)
  • (What versions of MIGX, MODX, PHP do you use?)

The csv file contains in the first line the names of the columns that correspond to the Field field.
Example csv:
tream;descr
ssave;text
two;text_2

Version Modx v3.1.1
php v.8.2.12
MIGX v. 3.0.2
File config
{
“formtabs”:[
{
“MIGX_id”:10,
“caption”:“golosary”,
“print_before_tabs”:“0”,
“fields”:[
{
“MIGX_id”:21,
“field”:“tream”,
“caption”:“\u041f\u043e\u043d\u044f\u0442\u0438\u0435”,
“description”:“”,
“description_is_code”:“0”,
“inputTV”:“”,
“inputTVtype”:“text”,
“validation”:“”,
“configs”:“”,
“restrictive_condition”:“”,
“display”:“”,
“sourceFrom”:“config”,
“sources”:“”,
“inputOptionValues”:“”,
“default”:“”,
“useDefaultIfEmpty”:“0”,
“pos”:1
},
{
“MIGX_id”:25,
“field”:“descr”,
“caption”:“\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435”,
“description”:“”,
“description_is_code”:“0”,
“inputTV”:“”,
“inputTVtype”:“”,
“validation”:“”,
“configs”:“”,
“restrictive_condition”:“”,
“display”:“”,
“sourceFrom”:“config”,
“sources”:“”,
“inputOptionValues”:“”,
“default”:“”,
“useDefaultIfEmpty”:“0”,
“pos”:2
}
],
“pos”:1
}
],
“contextmenus”:“”,
“actionbuttons”:“importcsvmigx”,
“columnbuttons”:“”,
“filters”:“”,
“extended”:{
“migx_add”:“”,
“disable_add_item”:“”,
“add_items_directly”:“”,
“formcaption”:“”,
“update_win_title”:“\u0413\u043e\u043b\u043e\u0441\u0430\u0440\u0438\u0439”,
“win_id”:“”,
“maxRecords”:“”,
“addNewItemAt”:“bottom”,
“media_source_id”:“”,
“multiple_formtabs”:“”,
“multiple_formtabs_label”:“”,
“multiple_formtabs_field”:“”,
“multiple_formtabs_optionstext”:“”,
“multiple_formtabs_optionsvalue”:“”,
“actionbuttonsperrow”:4,
“winbuttonslist”:“”,
“extrahandlers”:“”,
“filtersperrow”:4,
“packageName”:“”,
“classname”:“”,
“task”:“”,
“getlistsort”:“”,
“getlistsortdir”:“”,
“sortconfig”:“”,
“gridpagesize”:“”,
“use_custom_prefix”:“0”,
“prefix”:“”,
“grid”:“”,
“gridload_mode”:1,
“check_resid”:1,
“check_resid_TV”:“”,
“join_alias”:“”,
“has_jointable”:“yes”,
“getlistwhere”:“”,
“joins”:“”,
“hooksnippets”:“”,
“cmpmaincaption”:“”,
“cmptabcaption”:“”,
“cmptabdescription”:“”,
“cmptabcontroller”:“”,
“winbuttons”:“”,
“onsubmitsuccess”:“”,
“submitparams”:“”
},
“permissions”:{
“apiaccess”:“”,
“view”:“”,
“list”:“”,
“save”:“”,
“create”:“”,
“remove”:“”,
“delete”:“”,
“publish”:“”,
“unpublish”:“”,
“viewdeleted”:“”,
“viewunpublished”:“”
},
“fieldpermissions”:“”,
“columns”:[
{
“MIGX_id”:1,
“header”:“\u041f\u043e\u043d\u044f\u0442\u0438\u0435”,
“dataIndex”:“tream”,
“width”:200,
“sortable”:“false”,
“show_in_grid”:1,
“customrenderer”:“”,
“renderer”:“”,
“clickaction”:“”,
“selectorconfig”:“”,
“renderchunktpl”:“”,
“renderoptions”:“”,
“editor”:“”
},
{
“MIGX_id”:2,
“header”:“\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435”,
“dataIndex”:“descr”,
“width”:500,
“sortable”:“false”,
“show_in_grid”:1,
“customrenderer”:“”,
“renderer”:“”,
“clickaction”:“”,
“selectorconfig”:“”,
“renderchunktpl”:“”,
“renderoptions”:“”,
“editor”:“”
}
],
“category”:“\u0423\u0440\u043e\u043a\u0438”
}

By default the import processor uses the comma character (,) as the separator and NOT the semicolon (;).

The easiest way to fix the issue, is to change the import file to account for that.

Thank you very much, everything worked out!!!