-
☆ A M B ☆
- 397 Posts
I would like to create a dynamic listbox TV that shows options that are generated from a MIGX TV associated with its parent.
So in the parent resource, I can create filters that appear as listbox options in a TV linked to the children.
I have already solved it using an EVAL binding like this:
@EVAL return '-- choose a filter --||'.$modx->runSnippet('getImagelist',array('tvname'=>'filter.migx','tpl'=>'@CODE:[[+name]]==[[+value]]','outputSeparator'=>'||','docid'=>'10'));
My only problem is that in this case, I need to manually type in the parent ID (10) to get the MIGX values.
How can I change this so that it finds the parent ID dynamically and inserts it here in the docid value assignment?
Or does anyone have a better solution?
Thanks,
Ben
Benjamin Davis: American web designer living in Munich, Germany and a MODX Ambassador. I am also co-founder of SEDA.digital, a MODX Agency.
-
☆ A M B ☆
- 397 Posts
I am wondering if this is at all possible, because as the script runs before the form is made, does it know the id of the resource that is opening, so that it can search for a parent id at all? And if the resource would be a new resource, does it in fact have an id to obtain for this script to work properly?
Benjamin Davis: American web designer living in Munich, Germany and a MODX Ambassador. I am also co-founder of SEDA.digital, a MODX Agency.
not sure, if $modx->resource is avail at this time, but you can try it:
@EVAL return '-- choose a filter --||'.$modx->runSnippet('getImagelist',array('tvname'=>'filter.migx','tpl'=>'@CODE:[[+name]]==[[+value]]','outputSeparator'=>'||','docid'=>$modx->resource->get('parent'));
if not, you can try to use the
and get the resource-object and its parent
-
☆ A M B ☆
- 397 Posts
Hey Bruno,
That worked! $modx->resource->get('parent')
Benjamin Davis: American web designer living in Munich, Germany and a MODX Ambassador. I am also co-founder of SEDA.digital, a MODX Agency.
-
☆ A M B ☆
- 397 Posts
This method seems to not work anymore. Bruno, do you have any idea why?
Benjamin Davis: American web designer living in Munich, Germany and a MODX Ambassador. I am also co-founder of SEDA.digital, a MODX Agency.
may be $modx->resource->get('parent') isn't available in your situation