We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 53320
    • 1 Posts
    Hello

    I am fairly new to MODx and pretty desperate because i cannot find any working solution to my problem.

    I have set up a Listbox(Multiple Choice) with some resources to choose from which i pull with this:
    @EVAL return $modx->runSnippet('listResourcePagetitleInputOption', array('parent' => 99));

    This works perfectly and lets me choose from the child-elements (100,101,102) of the parent resource with the id 99.

    Resource structure:
    - Special (99)
    -- Option 1 (100)
    --- Sub Option 1 (103)
    --- Sub Option 1 (104)
    -- Option 2 (101)
    --- Sub Option 1 (105)
    -- Option 3 (102)

    Snippet-Code (listResourcePagetitleInputOption):
    <?php
    $parent = $modx->getOption('parent',$scriptProperties,0);
    $parentObj = $modx->getObject('modResource',$parent);
    if (!($parentObj instanceof modResource)) { return ''; }
    $resArray = $parentObj->getMany('Children');
    $resources = array();
    foreach($resArray as $res) {
      if ($res instanceof modResource) {
        $resources[] = $res->get('pagetitle');
      }
    }
    $out = implode("||",$resources);
    return $out;
    


    I am in need of a second Listbox which pulls the chosen id (for example id 100) of the first Listbox as his parent id (100) to get the child-elements with the ids 103 and 104 as a selectable option. Also it should be possible if i choose the Option 1 (100) and Option 2 (101) in the first Listbox, it should grab the children of all selected (103,104,105).

    Is there a way to achieve this? Any help is greatly appreciated!

    Thank you and best regards
    Sascha
      • 4172
      • 5,888 Posts
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!