We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4172
    • 5,888 Posts
    Quote from: eighthday at Apr 04, 2013, 01:12 PM

    firstRender shows the first option in a tv that has input options setup like this pagetitle:pageid, very handy!

    with renderChunk it should now also be possible to figure the pagetitle by given id.
    For example this could work in a renderChunk - chunk:

    [[getResourceField? &id=`[[+resource_id]]`]]
      -------------------------------

      you can buy me a beer, if you like MIGX

      http://webcmsolutions.de/migx.html

      Thanks!
      • 40045
      • 534 Posts
      Got a new warning showing (2.4.2beta3) with the same setup/config as shown before in the thread (just another migx tv) and it goes away as soon as I have made the first entry, so the warning occurs when the grid is empty/has no items in it, it also comes back if I delete all the items so the grid is empty again.

      Warning: Invalid argument supplied for foreach() in /var/www/modx/core/components/migx/model/migx/migx.class.php on line 925


      I actually noticed that the issue with the initially not rendering publish/unpublish images (which are shown when clicked once) just occurs with NEWLY ADDED items, when once saved and reloaded, the images show up correctly, so it seems that something isn't triggered when adding/duplicating an item to the grid...
        • 4172
        • 5,888 Posts
        try to add this line into 922:
        $outputrows = is_array($rows) ? $rows : array();
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 40045
          • 534 Posts
          Adding your suggestion did create the same warning:

          Warning: Invalid argument supplied for foreach() in /var/www/modx/core/components/migx/model/migx/migx.class.php on line 925


          I could make it go away with this:

                  $outputrows = is_array($rows) ? $rows : array();
                  if (count($columnrenderoptions) > 0) {
                      if (!empty($outputrows) ) { // added this check
                          $outputrows = array();
                          foreach ($rows as $row) {
                              foreach ($columnrenderoptions as $column => $options) {
                                  $row[$column . '_ro'] = isset($row[$column]) && isset($options[$row[$column]]) ? $this->modx->toJson($options[$row[$column]]) : '';
                                  foreach ($options as $option) {
                                      if ($option['_renderer'] == 'this.renderChunk') {
                                          $row['_this.value'] = $row[$column];
                                          $row[$column] = $this->renderChunk($option['name'], $row);
                                      }
                                      break;
                                  }
                              }
                              $outputrows[] = $row;
                          }
                      }
                  }
          
          [ed. note: exside last edited this post 13 years, 6 months ago.]
            • 40045
            • 534 Posts
            I just tried to implement the same functionality (switchButton/Icons) in a real migxdb CMP grid, I used exactly the same configuration as for the normal migx tv discussed in this thread, the only thing I changed is the fieldname from "published" to "extended.hitparade" as I will have to add several of these switch options to each grid row (but for now just one, to try out =D)...

            the cmp grid with 2 problems:
            1. the switchOption images (also) don't show, like in the setup discussed earlier (same reason, /undefined as img source) but with the additional issue, that a click doesn't have any action, the grid gets reloaded, a post is made, but it doesnt change the value of the extended field and also, unlike the other setup, a click doesn't show the cross/tick image
            2. the last column is a image tv with a local url in it, but when I turn on this.renderImage for that column (in MIGX configurator), the grid doesn't even load, no idea why...EDIT: this works now, PR sent on github, was because I had several empty image fields (null) which broke the grid and prevented renderImage from running...




            In the formtabs I have set up the field extended.hitparade as listbox type with input options Nein==0||Ja==1, default value 0



            in the columns I added the field extended.hitparade with the switchAction renderer as is shown below...



            I also ticked the this.handleColumnSwitch under handlers.




            is it even possible to use the switchActions on extended fields or any other ideas what I may be doing wrong?

            EDIT: seems like not, after looking into the code it seems to only respect "publish" / "unpublish" [ed. note: exside last edited this post 13 years, 6 months ago.]
              • 40045
              • 534 Posts
              Also regarding my last post in this thread.

              I tried to debug that "/undefined" as image source with columSwitch on problem. In configs/grid/grid.config.inc.php I found the code that handles the option switching, added some console.log() stuff to log what's going on. As I wrote, when clicked once, the images appear and also the console entry is shown, BUT NOT on initial page/grid load, so as guessed, there is the problem. I then tried to find out where that initial load of the grid is done, but really wasn't successful

              So @Bruno, could you may tell me what part of the code is loading the grid initially, then I would go there and have a look at the problem =)
                • 4172
                • 5,888 Posts
                Before I try to rebuild your scenario, I think it would be faster to have a look on it directly, if you want to send me a manager-login.
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 40045
                  • 534 Posts
                  Hi Bruno,

                  which scenario do you mean? The switchActions on extended fields or the problem with the not appearing images on initial load?
                    • 4172
                    • 5,888 Posts
                    I meant both of them. switchActions is working for me on different fields, not only on published, but didn't try it on extended fields.
                    And the status-images are allways there, also on initial load in MIGXdb-CMPs or MIGXdb-TVs
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 40045
                      • 534 Posts
                      Thank you Bruno for the help, things resolved:

                      1) Not appearing images on initial load: Replace the row with a renderChunk renderer and put in the switchActions html inside that chunk.

                      2) extended fields do not work with switchActions, but any other "physical" existing db field does