We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32424
    • 19 Posts
    I have a jQuery image rotating script that I found, which uses a line like this to call the images that get rotated:

    <?=$image_rotation; ?>

    When I save this as a snippet, MODx rewrites it thusly:

    <?php
    =$image_rotation;
    ?>

    And then I get this lovely error on the page with the script on it:
    Parse error: syntax error, unexpected ’=’ in /home/jademoun/public_html/manager/includes/document.parser.class.inc.php(769) : eval()’d code on line 1

    I understand why I get the error, but I can’t figure out how to resolve it. I understand that <?= is shorthand for something in PHP, but I’m not sure what, and that’s a hard thing to Google for. Any help would be appreciated!
      • 4041
      • 788 Posts
      Try it with this as your snippet code:

      <?php
      $output ="";
      $output .=$image_rotation;
      return $output;
      ?>
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        That’s shorthand for echo. You shouldn’t use echo in snippets, all output should be gathered into a variable and returned.
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org