We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20648
    • 26 Posts
    I have a migxdb
    I have created a TV, ChooseContactPerson, listbox(multiselect), with this input option values
    @EVAL return $modx->runSnippet('migxLoopCollection',array('tpl'=>'@CODE:[[+name]]','outputSeparator'=>'||','packageName'=>'employees','classname'=>'employee','where'=>'{"published" : "1"}'));

    This gives a listbox in admin, that user can select employee names. All working fine so long. But how can I show the data for only the selected name on front-end?
    I have tried to use the migxLoopCollection, but it seems not to fetch my TV, ChooseContactPerson.

    My call on front-end:
    [[migxLoopCollection?
    &packageName=`employees`
    &classname=`employee`
    &selectfields=`name,phone,email,image`
    &where=`{"name:in_array":"[[*ChooseContactPerson]]"}`
      &tpl=`@CODE: <p>[[+name]]<br/> [[+phone]]<br/> [[+email]]<br/> [[+image]]</p>`
     &debug=`0`
    ]]


    This call list all entries in migxdb. So how can I tell the snippet only to list, according to the names in the TV ChooseContactPerson?

    This question has been answered by Bruno17. See the first response.

      • 4172
      • 5,888 Posts
      try

      &where=`{"name:IN":[ [[*ChooseContactPerson:replace=`||==,`]] ]}`
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 20648
        • 26 Posts
        Hi, thank you for answer.
        No luck with the where clause. Is it a typo there? I tried
        &where=`{"name:IN":"[ [[*ChooseContactPerson:replace=´||==,´]] ]"}`

        I only get blank results.
        if I turn debug on. this is the output/query.
        SELECT `employee`.`name`, `employee`.`phone`, `employee`.`email`, `employee`.`image` FROM `modx_employees` AS `employee` WHERE `employee`.`name` IN '[ Elvis Presley ,Pink Floyd ]' 
        • discuss.answer
          • 4172
          • 5,888 Posts
          if would be better, to store only the ids, with

          @EVAL return $modx->runSnippet('migxLoopCollection',array('tpl'=>'@CODE:[[+name]]==[[+id]]','outputSeparator'=>'||','packageName'=>'employees','classname'=>'employee','where'=>'{"published" : "1"}'));


          and do it this way:

          &where=`{"id:IN":[ [[*ChooseContactPerson:replace=´||==,´]] ]}`

            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!