output"> output" />
New Community Forums are coming. Watch this space for news.
Subscribe: RSS
  • Hello there again!

    I'm trying to get the value of the fieldname "images" in a custom db, which holds the filename of uploaded images. It can be empty, a single filename or a comma-separated list of several filenames.

    [[!migxLoopCollection?
        &packageName=`myPackageName`
        &classname=`myClassname`
        &tpl=`myChunk`
        &sortConfig=`[{"sortby":"RAND()"}]`
        &limit=`25`
        &outputSeparator=`,`
        &where=`{"id:=":"[[+id]]"}`
    ]]
    

    With the above call I'm getting the desired value with the tpl "myChunk":

     <img src="[[+images]]" /> 



    But this is a comma-separated list, like this:

    /uploads/user_1/image1.png,/uploads/user_1/image2.jpg 


    So the source code looks like this:

     <img src="/uploads/user_1/image1.png,/uploads/user_1/image2.jpg" /> 


    I want to output the two images in a separate chunk. So I hoped the "&outputSeparator" attrtibute could help, but it doesn't. How can I achieve that? Do I have to edit the migxloopcollection-snippet? Any help is appreciated.

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

    • discuss.answer
      try to create a snippet to create the imagelist like this:

      $images = explode(',',$modx->getOption('images',$scriptProperties,''));
      $output = array();
      foreach ($images as $image){
          if (!empty($image)){
              $output[] = '<img src="' . $image . '" />';
          }
      }
      
      return implode('',$output);


      and call it with

      [[!prepareImages? &images=`[[+images]]`]]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
      • Hello Bruno!

        Thanks a lot again(!) for getting into my "problem" and helping me! You are the best!
        And sorry for the late "thank you" - real-life-jobs kept me busy during the last two weeks...

        The solution you posted is working, nice and thanks!

        I figured out that I can't use "pthumb" the "normal MODx-way" by using this

        	 [[!pthumb? &input=`[[+images]]` &options=`h=200` &toPlaceholder=`thumb`]] 


        but I guess it might be able by editing the "prepareImages-snippet".

        I'm gonna try to sort this out on my own...I hope! wink

        Kind regards to you!