We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42239
    • 73 Posts
    I have two migxdb tables with the following fileds:

    Clients:
    client_name
    phone
    email
    contact

    Projects
    name
    description
    client

    I want the projects field to be a single select listbox that contains the client_name of each row in the clients table.

    Also I'd like to be able to have a migx grid within a migxdb table to enter multiple images, like a gallery, in a field.

    is this possible?

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

    • discuss.answer
      • 4172
      • 5,888 Posts
      Both is possible.
      There are allready some posts at the MIGX - board in this forums related to this subjects.

      I want the projects field to be a single select listbox that contains the client_name of each row in the clients table.


      there are some different ways with @EVAL, @CHUNK or @SELECT - bindings in input-options for the inputTVtype of 'listbox'.
      I'm using it like that:

      @EVAL return 'choose one==||'.$modx->runSnippet('migxLoopCollection',array('packageName'=>'YourPackage','classname'=>'YourClassname','tpl'=>'@CODE:[[+id]]==[[+client_name]]','outputSeparator'=>'||','sortConfig'=>'[{"sortby":"client_name"}]'));


      another way with the @CHUNK - binding in input-options

      the chunk 'yourChunkName':
      choose one==||
      [[migxLoopCollection?
      &packageName=`YourPackage`
      &classname=`YourClassname`
      &tpl=`@CODE:[[+id]]==[[+client_name]]`
      &outputSeparator=`||`
      &sortConfig=`[{"sortby":"client_name"}]`
      ]]
      


      and put into input-option-values:

      @CHUNK yourChunkName



      Also I'd like to be able to have a migx grid within a migxdb table to enter multiple images, like a gallery, in a field.

      you just use inputTVtype of 'migx' and put in configurations the name of a MIGX-configuration and do the configurations for formtabs and columns within the MIGX-configurator-CMP



      [ed. note: Bruno17 last edited this post 12 years, 10 months ago.]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 42239
        • 73 Posts
        Thanks Bruno that did the trick. To get the migx grid inside the migxdb I just created a standard migx tv and used that as the input tv value. Seems to have worked. Is there anything wrong with doing it that way.
          • 4172
          • 5,888 Posts
          Nothing wrong, both ways (using inputTV and pointing to a MIGX-TV or inputTVtype and pointing to a MIGX-config) are valid ways.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 42239
            • 73 Posts
            Couple more things:

            I've worked out I need a custom renderer. I want it to work like the renderCrossTick for publish unpublished, but I want mine to just detect if there is anything inside the field.
            Heres what I have in my custom config file grid.notes.config.inc.php the option comes up in the render options but I get a blank <img src=undefined... on the migxdb grid. I guess I'm not sure what to use for a handler or maybe its just all wrong.

            <?php
            $img = '<img src="{0}" alt="{1}" title="{2}">';
            $renderer['this.renderHasIt'] = "
            renderHasIt : function(val, md, rec, row, col, s) {
                var renderImage, altText, handler, classname;
                
                switch (val) {
                    case 0:
                    case '0':
                    case false:
                        renderImage = '/assets/components/migx/style/images/cross.png';
                        handler = '';
                        classname = 'publish';
                        altText = 'No';
                        break;
                    case 1:
                    case '1':
                    case true:
                        renderImage = '/assets/components/migx/style/images/tick.png';
                        handler != '';
                        classname = 'unpublish';
                        altText = 'Yes';
                        break;
                }
                return String.format('{$img}', renderImage, altText, altText, classname, handler);
            }
            ";


            next:
            for my fronted output I have this:
            [[migxLoopCollection? &packageName=`notes` &classname=`notes` &tpl=`notesInner` ]]

            notesInner:
            <tr>
            	<td>[[+createdon]]</td>
            	<td>
            		<table>
            			<tr>
            				<td>[[+notes]]</td>
            			</tr>
            			<tr>
            				<td>
                                                [[migx +images output?]]
            				</td>
            			</tr>
            		</table>
            	</td>
            </tr>


            how would I output the images in the migx field. I'm sure it would be another migxLoop just not sure how to call specifically that data.
            uses migxtv name Gallery using [[+title]],[[+image]],[[+description]]
              • 4172
              • 5,888 Posts
              much simpler!

              use the renderChunk - renderer and put into the renderChunk Template - input something like that:

              [[+_this.value:is=``:then=`
              <img src="/assets/components/migx/style/images/cross.png">
              `:else=`
              <img src="/assets/components/migx/style/images/tick.png">
              `]]
              

              you can use
              [[+_this.value]]
              for the current field or placeholders of any other field.
              Its also possible to put snippet-calls into the renderChunk - Template.


              To get the images into your frontend-output do it this way:

              <tr>
                  <td>[[+createdon]]</td>
                  <td>
                      <table>
                          <tr>
                              <td>[[+notes]]</td>
                          </tr>
                          <tr>
                              <td>
                                  [[getImageList? &value=`[[+images]]` &tpl=`imageTpl`]]
                              </td>
                          </tr>
                      </table>
                  </td>
              </tr>
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 42239
                • 73 Posts
                Wow this is awesome, very versatile. Thats exactly what I needed. Thanks.
                  • 42239
                  • 73 Posts
                  Ok hopefully final question. Everything is working great and exactly as I need it to.

                  I need specific data to populate when someone logs in based on their project number assigned to them.

                  I'm using the comment field in the user profile to enter the number of the project.

                  [[+comment]] tested and works on page result = 1


                  [[migxLoopCollection? &packageName=`notes` &classname=`notes` &where=`{"project:=":"1"}` &tpl=`notesInner`]]

                  gives me the desired result, but when I replace 1 with [[+comment]] it breaks.

                  [[migxLoopCollection? &packageName=`notes` &classname=`notes` &where=`{"project:=":"[[+comment]]"}` &tpl=`notesInner`]]

                  Is there a solution for that?
                    • 4172
                    • 5,888 Posts
                    can you show the whole thing, please?

                    where is
                    [[+comment]]
                    coming from?

                    I think you may need to have that uncached:

                    [[!migxLoopCollection? &packageName=`notes` &classname=`notes` &where=`{"project:=":"[[!+comment]]"}` &tpl=`notesInner`]]
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 42239
                      • 73 Posts
                      The page would look like this:

                      [[!Profile]]

                      [[migxLoopCollection? &packageName=`notes` &classname=`notes` &where=`{"project:=":"[[+comment]]"}` &tpl=`notesInner`]]

                      [[+comment]] is just the comment section in the user profile that has the project number in it.

                      The idea is someone logs in, redirected to this page and they see only the project notes with their assigned project id.

                      In this case my test has 1 assigned to comment which should net me the same results as:
                      [[migxLoopCollection? &packageName=`notes` &classname=`notes` &where=`{"project:=":"1"}` &tpl=`notesInner`]]

                      but it somehow seems to break it like it can't handle the placeholder