MODX Community

TV output that populates another TV's list

I’m trying to make a TV that looks something like this:

Item - Percentage

Where each category will have multiple items. But I want the option to have multiple categories too. The catch is that I won’t know how many categories I’ll need until later. So I’d like to have one TV that defines the categories and another TV that creates a list to select from based on the category TV and then I’ll assign items to each of those.

I know I could manually create a dropdown field in MIGX and just add them there for each category, but I’d like to make this dynamic if I can.

Is this even possible to do? Or is there a better way to achieve this?


You can fill a dropdown dynamically with the values from a MIGX TV if you put code like this into the field ‘Input Option Values’.

@EVAL return "--- Choose Category ---==||".$modx->runSnippet('getImageList',array('tpl'=>'@CODE:[[+categoryName]]==[[+MIGX_id]]','outputSeparator'=>'||','tvname'=>'categories','docid'=>'10'));

does the docid matter? Where did the 10 come from? Or is that the resource id?

Yes, that is just the resource id. You can probably omit it, if the 2 MIGX TVs are defined on the same page.