How to get MIGX values in different TV on the same resource

i have 2 MIGX TV

1 TV is categories just 1 text field e.g. CAT1, CAT2 etc
2 TV is image which got image, title and category

Now on TV 2 the category field should be taken from TV1 as a multi select TV. so that you can select one or more categories per MIGX entry.

Both TV sit in the same resource

how can this be done on MIGX or any other way when creating an image sorter where the category fields are dynamically added via a TV on each resource?

thanks!

In the “multi select TV”, in the field “Input Option Values” you can use a @CHUNK (or a @SNIPPET) binding. Then in the chunk, call getImageList (or some custom snippet) to get the available options.


With MIGX TVs, you have to fill in the “categories TV” first, then save the resource, and only then you can start filling in the “image TV”.

Using MIGXdb TVs instead, would probably improve the handling for the user.

Awesome many thanks. I thought as much jsut could not get it right.

Question how do I get the chunk to render the getimageList. As the way you explained it just imports the code in the chunk ie the getImageList call.

Do I need to write a custom snippet for that or is there a easier way?

Many thanks

Putting a normal snippet tag [[getImageList? ...]] in the chunk should work.

If it doesn’t work, maybe you can share your MIGX config?

Sure I have

{
“formtabs”:[
{
“MIGX_id”:7,
“caption”:“gallery”,
“print_before_tabs”:“0”,
“fields”:[
{
“MIGX_id”:14,
“field”:“title”,
“caption”:“title”,
“description”:“”,
“description_is_code”:“0”,
“inputTV”:“”,
“inputTVtype”:“”,
“validation”:“”,
“configs”:“”,
“restrictive_condition”:“”,
“display”:“”,
“sourceFrom”:“config”,
“sources”:“”,
“inputOptionValues”:“”,
“default”:“”,
“useDefaultIfEmpty”:“0”,
“pos”:1
},
{
“MIGX_id”:15,
“field”:“image”,
“caption”:“image”,
“description”:“”,
“description_is_code”:“0”,
“inputTV”:“”,
“inputTVtype”:“imageplus”,
“validation”:“”,
“configs”:“”,
“restrictive_condition”:“”,
“display”:“”,
“sourceFrom”:“config”,
“sources”:“”,
“inputOptionValues”:“”,
“default”:“”,
“useDefaultIfEmpty”:“0”,
“pos”:2
},
{
“MIGX_id”:39,
“field”:“category”,
“caption”:“category”,
“description”:“”,
“description_is_code”:“0”,
“inputTV”:“”,
“inputTVtype”:“listbox-multiple”,
“validation”:“”,
“configs”:“”,
“restrictive_condition”:“”,
“display”:“”,
“sourceFrom”:“config”,
“sources”:“”,
“inputOptionValues”:“@CHUNK galerySorterValues”,
“default”:“”,
“useDefaultIfEmpty”:“0”,
“pos”:3
}
],
“pos”:1
}
],
“contextmenus”:“”,
“actionbuttons”:“”,
“columnbuttons”:“”,
“filters”:“”,
“extended”:{
“migx_add”:“”,
“disable_add_item”:“”,
“add_items_directly”:“”,
“formcaption”:“”,
“update_win_title”:“”,
“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”:“title”,
“dataIndex”:“title”,
“width”:“”,
“sortable”:“false”,
“show_in_grid”:1,
“customrenderer”:“”,
“renderer”:“”,
“clickaction”:“”,
“selectorconfig”:“”,
“renderchunktpl”:“”,
“renderoptions”:“”,
“editor”:“”
},
{
“MIGX_id”:2,
“header”:“image”,
“dataIndex”:“image”,
“width”:“”,
“sortable”:“false”,
“show_in_grid”:1,
“customrenderer”:“”,
“renderer”:“ImagePlus.MIGX_Renderer”,
“clickaction”:“”,
“selectorconfig”:“”,
“renderchunktpl”:“”,
“renderoptions”:“”,
“editor”:“”
}
],
“category”:“”
}

and my chunk sorterValTpl got
[[!getImageList?
&tvname=sorter
&tpl=sorterValTpl
&limit=7
]]

Try using a chunk galerySorterValues like this:

[[getImageList?
    &tvname=`sorter`
    &tpl=`@CODE:[[+some_field]]==[[+MIGX_id]]`
    &limit=`0`
    &outputSeparator=`||`
]]

or maybe

[[getImageList?
    &tvname=`sorter`
    &tpl=`@CODE:[[+some_field]]`
    &limit=`0`
    &outputSeparator=`||`
]]

The output has to be in the form value1==id1||value2==id2||value3==id3 or value1||value2||value3.

Hi thats what more or less what I had in the chunk ie sorterValTpl as code above but the output it literally the chunk unrendered.

I also tried making a normal TV and then calling it as a TV in migx same thing happens

The issue is not the actual getIMage list call but that in MIGX it call the content of the chunk ie it will call the text in other words the getImageList call and displays that vs what the getimagelIst call is suppose to render
I hope i explained that right

What exact versions of MODX and MIGX are you using?

When I test it with MODX 2.8.4 and MIGX 3.0.0-alpha5, the snippet gets parsed correctly.

3.0.3-pl and 3.0.0-alpha5

I will do a test on 2.8.4

I only have a installation with MODX 3.0.3-pl and MIGX 3.0.0-beta1, but there it works correctly as well.

Does it work when you use a normal listbox TV with a @CHUNK binding on your system (without using MIGX at all)?

same thing. what php version are you running i am running PHP Version 8.0.28

i wonder why it wont render

I tested it with PHP 7.4 and 8.1.
I don’t think it’s a PHP issue.


Does it work with any other snippet?

For example: @CHUNK galerySorterValues
Chunk “galerySorterValues”:

[[getMyOptions]]

Snippet “getMyOptions”:

<?php
return "cat1||cat2||cat3";

snippet works fine and also works if I manually enter the value into the chunk but it does not run getImage

I also tried to reinstall migx no luck

could it be that migx plugin needs to be executed at a specific system event to render?

This sounds more like a MODX parser issue to me, than some problem with MIGX.

When you use the exact same chunk (galerySorterValues) in a resource, does this produce the correct output on the frontend?

I managed to fix it.

However I do no know how or why but its working now. I eneded up testing the same code and setup on a different website and it worked.

So I reinstalled modx fresh and its working now. I am not sure what the issue was though.

I copied and pasted the same code that you suggested and now it works, very happy.

many thanks for all your help you are a support legend here on the forum

1 Like

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.