We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38314
    • 45 Posts
    Hi,

    I met the same problem with a blog system : I wanted to display in the start page a block in which there is the 5 last news [[*introtext]] with a little thumbnail, which was a TV managed by MIGX.
    I used : Collection, MIGX (getImageList snippet and dynamic Mediasource as explained in the documentation) and getResources !
    I had the same result as mentionned upper : the first row was the introtext with the good image. But the others rows couldn't display the good image. When I watched the path to the image, the entire path was good but the resource ID. The resource ID for every path was the ID of the first row...

    After few hours, I decided to change getResources to pdoResources and that worked, with a little snippet of my own to simplify MIGX's getImageList snippet. I guess this is optionnal but I didn't test back with as it was working as expected.

    Here's my schema :
    -> my resource 55 : display results
    --> pdoResources snippet : query the data
    ---> ArticlesThumb chunk : display every row
    ----> getJsonList snippet : transform TV json in array Php
    -----> thumbTpl chunk : only for the image
    You can see all these are nested !


    Here are my chunk and snippet if it can help !

    The snippet getJsonList
    <?php
    /**
     * 
     *  Return TV JSON values in tpl
     * 
     * 
     *  [[getJsonList?
     *      &docid=`99`         -- ID of ressource where there is the TV. ([[+id]], or 99) 
     *      &tvname=`mytv`      -- Name of the TV created with MIGX
     *      &tpl=`mytpl`        -- name of tpl
     * ]]
     * 
     * 
     * 
     **/
    
    
    $output ='';
    
    /* Let's get the snippet properties  */
    $tpl = $modx->getOption('tpl', $scriptProperties);
    $docid = $modx->getOption('docid', $scriptProperties);
    $tvname = $modx->getOption('tvname', $scriptProperties);
    if (empty($docid) or empty($tvname)) {
      return '<!-- docid or tvname empty -->';
    }
    
    /* Let's get the resource now */
    $resource = $modx->getObject('modResource',array('id'=> $docid));
    /* and the TV JSON */
    $strJSON = $resource->getTVValue($tvname);
    /* let's transform JSON in array */
    $array = $modx->fromJSON($strJSON);
    
    /* let's process the array */
    foreach($array as $result)
    {
       // print_r($arrJSON); //debug
       $image = $result[image];
       $title = $result[title];
       $description = $result[description];
    }
    
    /* send the values in tpl definied in properties */
    $output = $modx->getChunk($tpl,array(
      'image' => $image,
      'title' => $title,
      'description' => $description,
    ));
    return $output;


    thumbTpl : The chunk tpl in which the image is rendered
    <img src="path/to/my/media/[[+id]]/[[+image]]" title="[[+title:default=`[[+image]]`]]" alt="[[+image]]"/>


    ArticlesThumb : The chunk row where the image and the text are get
            <h2><a href="[[~[[+id]]]]">[[+pagetitle]]</a></h2>
                [[getJsonList?
                &tvname=`thumb`
                &docid = `[[+id]]`
                &tpl=`thumbTpl`]]
            [[+introtext:striptags:ellipsis=`300`:default=`[[+content:striptags:ellipsis=`160`]]`]]
        
    


    Call this in the page you want the result :
    [[pdoResources? 
    &parents=`55` 
    &depth=`0` 
    &showHidden=`1` 
    &limit=`3` 
    &tpl=`ArticlesThumb` 
    &includeTVs=`thumb` ]]


    Hope it's enough clear and it can help. You can and the snippet in MIGX if you want !

    PS : MIGX is really a must have for MODX as it is really brillant !!! Thanks Bruno17 !
      • 16899
      • 284 Posts
      Hi have exactly this problem... i have not an inline template, but inside my Tpl chunk i have not the phpthumbof snippet working as expected.

      Can anyone have a look here?
      http://forums.modx.com/thread/98985/phpthumbof-don-t-return-cached-images

      Many thanks
        • 36446
        • 184 Posts
        Quote from: spackko at Oct 09, 2014, 05:54 PM
        same here ..

        I have a pdoResources call like
        [[pdoResources?
        
           &parents=`[[*id]]`
           &limit=`99`
           &includeTVs=`tv.test-migx-tag`
           &processTVs=`1`
        
           &tpl=`test.chunk.list`
        
        ]]


        That lists some resources with text image etc.
        That works.
        Inside that template test.chunk.list
        I call another chunk with the getImage-call.

        That gives me always the first migx values .

        If I put that getImage call directly into my test.chunk.list I get the correct values ....

        Thanks for this post! I was struggling with the same issue for quite some time but now i got it working. I was just not possible to call my GetImageList inside a chunk. Calling it directly solved the problem!
          https://www.beautyislife-shop.de - premium make-up!
          https://www.topsterne.de - sell it here!
          ---------------------------------------------------------
          • 4172
          • 5,888 Posts
          each MODX-tag, which has different outputs from iteration to iteration has to have a unique footprint.

          for example:
          [[$yourchunk? &docid=`[[+id]]`]]


          otherwise, you will allways get the output of the first chunk, placeholder, snippet.... with the same footprint.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!