Populate Dropdown in MIGX TV from other MIGX TV

I have a MIGX TV team which stores information about team members on the resource Team with ID 4:

{"caption":"Text", "fields": [
{"caption":"Image", "fields":[

From that TV I want to fetch the name and email to be displayed within another resource where a schedule is displayed, where each entry is assigned to a team member and the email should be displayed.

I have a new listbox TV teamEmail created with the input option value:

@EVAL return $modx->runSnippet('getImageList',array('docid'=>'4','tpl'=>'@CODE:[[+name]]','outputSeparator'=>'||','tvname'=>'team'));

Now on the schedule resource I have another MIGX TV courses where I implemented the teamEmail TV:


When I fill in the data in the courses TV I see a filled dropdown list with the names of the team members like it’s supposed to be.

Now displaying the email in the frontend doesn’t work, I use this code to fetch the email without success so far:

[[getImageList? &where=`{"name":"[[*teamEmail]]"}` &tvname=`team` &tpl=`@CODE:[[+email]]` &docid=`4`]]

I used this old thread as reference. Any ideas?

I’m not quite sure where you call [[getImageList? &where=..., but try this.
Add a first call to getImageList to your resource to get all the courses.

[[getImageList? &tvname=`courses` &tpl=`tplCourse`]]

Then in the Chunk tplCourse add a second call to getImageList to read the email-address for this course.

[[getImageList? &where=`{"name":"[[+moInfo]]"}` &tvname=`team` &tpl=`@CODE:[[+email]]` &docid=`4`]]

things to check:

start simple to test, if you get anything with:

[[getImageList? &tvname=`team` &tpl=`@CODE:[[+email]]` &docid=`4`]]

do you get the correct name with


try to hardcode the name in the where - statement for testing

1 Like

@halftrainedharry Sorry, I skipped that part so my question doesn’t get too long, but how you describe it is exactly how I do it.

By using this I get all emails from all team members at once.

Just using [[*teamEmail]] on the courses template gives me the placeholder entry “-- please select --” which is probably the reason this is not working as there is no second value attached to that, so the result stays empty.

Hardcoding the name does work and outputs the right email, so I guess it is the [[*teamEmail]] part which doesn’t work. Do I have to call it differently as it’s within another MIGX TV?

Please check my solution again. You have to use [[+moInfo]] in your call to getImageList instead of [[*teamEmail]]!

1 Like

Oh my… you are right! :man_facepalming:
Thank you, that works of course!

You could also improve your code if you use the MIGX_id to store the reference to the team member instead of the name.

Use this code in your TV teamEmail

@EVAL return $modx->runSnippet('getImageList',array('docid'=>'4','tpl'=>'@CODE:[[+name]]==[[+MIGX_id]]','outputSeparator'=>'||','tvname'=>'team'));

and this code to read the email-address

[[getImageList? &where=`{"MIGX_id":"[[+moInfo]]"}` &tvname=`team` &tpl=`@CODE:[[+email]]` &docid=`4`]]

Now a change to the name-field of the team member will not break your code.

Really appreciate the effort, but this doesn’t seem to work? Not sure how to troubleshoot here now…

Maybe you could output [[+moInfo]] directly and check the value. It should be a number now.
You probably have to select the name from the dropdown list again to see the change.

If you have access to the database you could also check the table modx_site_tmplvar_contentvalues where the tmplvarid is equal to the IDs of your TVs team and courses. The value should look something like this.

	{"MIGX_id":"1","name":"John Doe","description":"","email":"john.doe@domain.com","image":""},
	{"MIGX_id":"2","name":"Jane Doe","description":"","email":"jane.doe@domain.com","image":""}
	{"MIGX_id":"1","name":"Course 1","moInfo":"1", ...}

Make sure the value in modInfo corresponds to the correct MIGX_id in team.

I had to reselect the the names again, works now! Thanks alot!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.