We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36605
    • 70 Posts
    Hey guys, so it’s been a long time and my skill with ModX has grown dramatically (to the point that I can actually post in this part of the forum cool!) However, I’m running into a problem right now and I can’t figure it out.

    So, in trying to make myself a jquery slider for a site, I realizetod I would have to list all the images from a certain in li blocks (how the script I downloaded works). Right now, I have the js in a chunk linking into [[getPics? &id=`[[+pagetitle]]`]] in between the ul blocks. Here’s the script for getPics:
    <?php
    $source = '/images/' . $id;
    $pics = scandir($source);
    $count = 0;
      foreach($pics as $pic) {
                             $output[$count] = modx->getChunk('picTpl',array('file'=>$pic));
                             $count++;
                             $content() .= $output[$count]; 
    };
    return $content;
      ?>
    ​


    Now for some reason whenever I try and go the test page I put the chunk into, it says "Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home2/djharryr/public_html/core/cache/elements/modsnippet/7.include.cache.php on line 11"


    I have no idea why, and am quite confused. Any help would be appreciated embarrassed


    Also, I realize I went about some of this in a really convoluted manner so if you want to critique the code (as harshly as you wish) it would also be a great learning experience! grin


    Thanks,
    Alex
      • 28215
      • 4,149 Posts
      $output[$count] = modx->getChunk('picTpl',array('file'=>$pic));


      should be:

      $output[$count] = $modx->getChunk('picTpl',array('file'=>$pic));


      Note the $ in front of modx.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com