We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28000 ☆ 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.
      • 28000 ☆ 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.
        • 4172
        • 5,888 Posts
        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
        $_REQUEST['id']
        and get the resource-object and its parent
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 44565
          • 15 Posts
          Hi Ben, hi Bruno,

          many thanks for this solution. The following solution works fine:

          Quote from: Bruno17 at Aug 29, 2013, 03:57 AM

          @EVAL return '-- choose a filter --||'.$modx->runSnippet('getImagelist',array('tvname'=>'filter.migx','tpl'=>'@CODE:[[+name]]==[[+value]]','outputSeparator'=>'||','docid'=>$modx->resource->get('parent'));

          Servus from munich
          Ralf

            • 28000 ☆ 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.
              • 28000 ☆ 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.
                • 4172
                • 5,888 Posts
                may be $modx->resource->get('parent') isn't available in your situation
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!