On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • SOLVED - SEE FIRST ANSWER

    I am trying to set up a custom imageRenderer Snippet for my Collections view. I want to display the first image of a MIGX-TV which hosts some images.

    So I made this Snippet:
    $row = $modx->getOption('row', $scriptProperties, '');
    $rowId = $row['id'];
    
    $modx->setPlaceholder('getId', $rowId);
    
    $gR = $modx->runSnippet('getResources', [
    'parents' => '-1',
    'resources' => $rowId,
    'tpl' => 'ref-image-id'
    ]);
    
    return '<a href="[[++site_url]]manager/?a=resource/update&id=' . $row['id'] . '" title="' . $row['pagetitle'] . '"><img src="' . $gR . '" width="60" ></a>';


    In my Chunk ref-image-id I have this (only works cached):
    [[getImageList?
    &tvname=`ref-images`
    &tpl=`ref-image-item`
    &docid=`[[+getId]]`
    &limit=`1`
    ]]


    The ref-image-item Chunk:
    [[++site_url]][[+image]]


    On my Collections view all of the images have the path of the first resource. The image itself ([[+image]]) is correct.
    What I get is:

    path/of/resource-1/car.jpg
    path/of/resource-1/flower.jpg
    path/of/resource-1/house.jpg

    when it should be:

    path/of/resource-1/car.jpg
    path/of/resource-2/flower.jpg
    path/of/resource-3/house.jpg

    I have tried this without the placeholder and inside my getImageList call using &docid=`[[+id]]` - same problem.

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

    [ed. note: aaantz last edited this post 1 year, 8 months ago.]
    • discuss.answer
      SOLVED

      https://forums.modx.com/thread/80762/getimagelist-used-in-getresources-rowtpl-only-shows-data-from-first-item#dis-post-484671

      I changed the Media Source:

      [[!migxResourceMediaPath? &pathTpl=`assets/resourceimages/{id}/`]]
      instead of
      [[migxResourceMediaPath? &pathTpl=`assets/resourceimages/{id}/`]]