We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37032
    • 64 Posts
    @jaredloman

    It outputs the string-URL to the uploaded file. Maybe it's better to use length to see if it's empty or not.
      • 14951
      • 151 Posts
      Hey tomahl,

      Sorry about the delay, I wasn't subscribed to this thread.

      So if the the tag just outputs the url, then we have a problem... getImageList as I understand it is looking for a JSON array. Are you sure the input type of your TV is set to MIGX? What does your Form Tabs and Grid Columns contain? I'll subscribe to this so I can tell when you reply.

      -Jared
        • 1331
        • 129 Posts
        Quote from: Bruno17 at Jul 08, 2011, 08:14 AM
        Quote from: prioritypie at Jul 08, 2011, 07:29 AM

        Thank you Bruno,

        The problem I was having was that a "Resource List" TV type just outputs the ids, so I couldn't have the pagetitle included in the option string and I was trying to get it from within the (grid) rendering function. I've resorted to using a standard drop down list TV with a snippet to output the relevant resources in the pagetitle:id format as you suggested.

        to complete this, the snippet-code for getResourceList:

        <?php
        $parent=$modx->getOption('parent',$scriptProperties,'0');
        $sortby=$modx->getOption('sortby',$scriptProperties,'pagetitle');
        
        $c = $modx->newQuery('modResource');
        $c->where(array('parent'=>$parent));
        $c->sortby($sortby);
        $collection = $modx->getCollection('modResource',$c);
        
        $output='kein Partner==0';
        foreach ($collection as $o){
        $output .= '||'.$o->get('pagetitle').'=='.$o->get('pagetitle').':'.$o->get('id');
        }
        return $output;


        and then use this input-option-values:
        @EVAL return $modx->runSnippet('getResourceList',array('parent'=>'3'));

        Hello Bruno,

        Thanks for these solutions. They're extremely helpful. I just tried the instructions mentioned here to get the Resource List to show the page name in the grid, but I haven't been successful yet.

        Can you explain a little more where these pieces of code should be?
          • 37032
          • 64 Posts
          Quote from: jaredloman at Sep 26, 2011, 06:27 PM
          Hey tomahl,

          Sorry about the delay, I wasn't subscribed to this thread.

          So if the the tag just outputs the url, then we have a problem... getImageList as I understand it is looking for a JSON array. Are you sure the input type of your TV is set to MIGX? What does your Form Tabs and Grid Columns contain? I'll subscribe to this so I can tell when you reply.

          -Jared

          Hi jaredloman,

          The TV's input type is set to MIGX, so nothing wrong there. This is what the form and tab looks like:

          Form:
          [
          	{"caption":"Fil", "fields":[
          		{"field": "productDoc", "caption": "Fil", "inputTV": "productDocFile"},
          		{"field": "productDocTitle", "caption": "Titel"}
          	]}
          ]

          Grid:
          [
          	{"header": "Fil", "width": "50", "sortable": "false", "dataIndex": "productDoc","renderer": "this.renderImage"},
          	{"header": "Titel", "width": "160", "sortable": "true", "dataIndex": "productDocTitle"}
          ]


          Thanks for your assistance.
            • 4172
            • 5,888 Posts
            Quote from: waivor at Sep 06, 2011, 03:15 AM
            Sorry, but I get an error with the code of dzes. I'm using PHP5 and by calling the mergeMigx snippet I get this error
            core/cache/includes/elements/modsnippet/53.include.cache.php : 324) PHP warning: implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed


            53 is the getImageList Snippet. If I use the original code of Bruno17 I get another error

            includes/elements/modsnippet/57.include.cache.php 16) PHP warning: array_merge() [<a href='function.array-merge'>function.array-merge</a>]: Argument #1 is not an array


            57 is the mergeMigx Snippet. But this error should be the one dzes also explained (array_merge() changes in PHP5).

            mergeMigx call:
            [[!mergeMigx?
                &tvname=`commercialRubric`
                &docid=`42`
                &tpl=`commercialRubricOutputInner`
                &where=`{"publishPage:=":"[[*id]]"}`
                &limit=`10`
             ]]


            Edit: I'm using Migx 1.1.0 rc2

            what happens with this code:

            <?php
            
            //[[mergeMIGX? &tvname=`mymigxtv` &docids=`10,11,12` &tpl=`mytpl` &debug=`1`]]
            
            $docids = explode(',', $docids);
            if ($tv = $modx->getObject('modTemplateVar', array('name' => $tvname))) {
                $allitems = array();
                foreach ($docids as $docid) {
                    $outputvalue = $tv->renderOutput($docid);
                    $items = $modx->fromJSON($outputvalue);
                    if (is_array($items)) {
                        $allitems = array_merge($allitems, $items);
                    }
                    elseif ($debug) {
                        echo 'Fehler in '.$docid.':'.$outputvalue;
                    }
            
                }
                $scriptProperties['value'] = $modx->toJSON($allitems);
            }
            
            return $modx->runSnippet('getImageList', $scriptProperties);
            
            ?>

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

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 36591
              • 38 Posts
              Quote from: Bruno17 at Oct 05, 2011, 01:30 AM


              what happens with this code:

              <?php
              
              //[[mergeMIGX? &tvname=`mymigxtv` &docids=`10,11,12` &tpl=`mytpl` &debug=`1`]]
              
              $docids = explode(',', $docids);
              if ($tv = $modx->getObject('modTemplateVar', array('name' => $tvname))) {
                  $allitems = array();
                  foreach ($docids as $docid) {
                      $outputvalue = $tv->renderOutput($docid);
                      $items = $modx->fromJSON($outputvalue);
                      if (is_array($items)) {
                          $allitems = array_merge($allitems, $items);
                      }
                      elseif ($debug) {
                          echo 'Fehler in '.$docid.':'.$outputvalue;
                      }
              
                  }
                  $scriptProperties['value'] = $modx->toJSON($allitems);
              }
              
              return $modx->runSnippet('getImageList', $scriptProperties);
              
              ?>


              What happens is: "Fehler: " and that's it. Seems to work but I'll test it carefully this afteroon.

              Edit: Well I don't get any error messages but I always get an empty output. The snippet is running but somehow getImageList doesn't seem to work ...

              Nothing happens:
              [[mergeMigx?
              &tvname=`commercialReview`
              &docid=`41`
              &tpl=`commercialReviewOutputInner`
              &where=`{"publishPage:=":"[[*id]]"}`
              &limit=`10`
              &debug=`1`
              ]]


              I'll get something with:


              [[!getImageList?
              &tvname=`commercialReview`
              &tpl=`commercialReviewOutputInner`
              &limit=`1`
              &docid=`41`
              &where=`{"publishPage:=":"[[*id]]"}`
              ]]
              [ed. note: waivor last edited this post 14 years, 11 months ago.]
                • 4172
                • 5,888 Posts
                you need

                &docids=`41`


                for mergeMIGX, but it doesn't make any sense to merge MIGX-outputs with only one resource-id
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 1331
                  • 129 Posts
                  I have a MIGX TV working that has dates in it. Is there a way to somehow tell MIGX to only output if the chosen date is later than x, or better yet, later than "right now"?
                    • 4172
                    • 5,888 Posts
                    create a snippet called 'strftime' :

                    <?php
                    return strftime($format);


                    and use it this way, when your date-field is called 'date' :
                    &where=`{ "date:>" : "[[!strftime? &format=`%Y-%m-%d`]]" }`
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 14951
                      • 151 Posts
                      @tomahl

                      I just paid a little bit more attention to your issue. The reason you are experiencing a problem is that currently (for what reason, I do not know) when you clear the MIGX tv from the manager the first is left with "[]" in the database which is probably why the content is still showing. You may have to go in and manually remove the "[]" from the database.

                      Although, it simply clearing the cache works, you might just try calling getImageList uncached. Depending on how big the site is and the number of resources you have, that may or may not be a good idea though...

                      This discussion is closed to further replies. Keep calm and carry on.