We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30107
    • 44 Posts
    First of all let me say that I absolutely fell in love with the fantastic MIGX addition. We use it to generate cleanly formatted pages. For normal content editor folks it's much more user friendly than the TinyMCE editor on it's own.

    But I have some problems with a MIGX template chunk, which gets more and more complex, because it makes heavy use of input/output filters.

    My MIGX tv is called like:

    [[getImageList? &tvname=`tvInhaltsseiteMIGXHauptinhalt` &tpl=`chkMIGXHauptinhalt`]]


    The template chunk "chkMIGXHauptinhalt" contains some if/else statements. Just to give an example (I shortened it):

    [[+dateiauswahl:notempty=`
      <div class="datei clearfix">
        <div class="icon">
          <a href="[[+dateiauswahl]]" target="_blank"><img src="[[+icon:is=`pdf`:then=`[[phpthumbof? &input=`assets/templates/img/icons/pdf.png` &options=`&w=60&zc=1`]]`:else=``]][[+icon:is=`rtf`:then=`[[phpthumbof? &input=`assets/templates/img/icons/rtf.png` &options=`&w=60&zc=1`]]`:else=``]][[+icon:is=`zip`:then=`[[phpthumbof? &input=`assets/templates/img/icons/zip.png` &options=`&w=60&zc=1`]]`:else=``]]" width="60" alt="[[+icon:ucase]]" /></a>
        </div>
        <div class="link">
          <a href="[[+dateiauswahl]]" target="_blank">[[+linktext]]</a>[[+beschreibung:notempty=` [[+beschreibung]]`]]
        </div>
      </div>
    `]]


    It seems to get more and more confused and clumsy to me...
    For example, it's not possible to use placeholders in the phpthumbof call, like
    [[phpthumbof? &input=`assets/templates/img/icons/[[+icon]].png` &options=`&w=60&zc=1`]]

    Sometimes I have to write ":else=``" at the end of an if/else statement in order to get it work, sometimes not...

    I think I would feel more comfortable if I could use a snippet with solid php if/else statements than these MODX input/output filters. My question is: How do I get the output of the MIGX snippet as an useable array to another snippet? I tried:

    $output = $modx->runSnippet('getImageList', array(
       'tvname' => 'tvInhaltsseiteMIGXHauptinhalt'
    ));


    In this case, $output just contains a string. I would like to get the "real" array and do foreach on each dataset by myself. Is this possible? Are there better alternatives?

    Thanks a lot for useful hints.

    PS: I have always wondered why there is a property "width" in the MIGX tv's grid column field. What does it do? It seems to have no effect to me.
      • 4172
      • 5,888 Posts
      I would create a custom-getImageList-snippet and put the logic in it.

      Its also possible to let getImageList output a json-string with &toJsonPlaceholder, if that helps.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 30107
        • 44 Posts
        Thank you Bruno for your helpful reply! Today, I skipped getImageList altogether and parse the raw JSON string of the MIGX TV like this:

        $strJSON = $modx->resource->getTVValue('myMigxTv');
        $arrJSON = $modx->fromJSON($strJSON);
        
        foreach($arrJSON as $arrJSONDataSet)
        {
          foreach($arrJSONDataSet as $key => $value)
          {
            echo $key . ' => ';
            echo $value;
            echo '<br />';
          }
        }

        now everything is in a key and value pair and I can apply the logic - great! smiley

        Another short question (I hope you don't mind): what does the parameter "width" in the MIGX grid columns do? I didn't find a hint for this in the docs. It's set in the following example:

        {"header": "Bild", "width": "200", "sortable": "false", "dataIndex": "bildauswahl", "renderer": "this.renderImage"},


        What does it effectively do? I don't see any change in backend, no matter what I set.
          • 4172
          • 5,888 Posts
          the width-parameter should have effect to the width of the column, but, I know, it doesn't.

          Hadn't the time to explore its reason.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!