We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12556
    • 103 Posts
    I’m about to attempt to write my first snippet because I need to have a small slideshow on a page that’s dynamically populated with whatever images are in a specified directory. I created a snippet and called it ProjectImages. In an attempt to make sure I understood how the data would be output, the only code I put in it is return "testing"; I then placed the snippet call in my template like so: [!ProjectImages!] I expected to see the text "testing" on the page but instead the template just outputs the snippet call verbatim. What am I doing wrong?
    Dave


      • 7231
      • 4,205 Posts
      There is a snippet that does what you describe (it uses an outdated Javascript but the part that reads the folder contents works) called SimpleSlideShow.

      Tips for troubleshooting snippet development:
      1) check the spelling and case. resources are case sensitive.
      2) check the system events report (manager > Reports > System Events) for any clues
      3) Try reversing the cache [[ ]] or [! !]
      4) Make sure you have the <?php ?> tags in your snippet code
      5) post your snippet code in the forum for help
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don&#39;t know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 3785
        • 143 Posts
        Did you use
        return "testing";
        or
        echo("testing");


        The first example will not generate any output on the screen.
          Medianotions – Studio für Webdesign
          http://www.medianotions.de
          • 12556
          • 103 Posts
          Interesting. Changing the snippet call from [! !] to [[ ]] did the trick. Does that have something to do with the fact that the snippet is being called from within a chunk being used by a call to Ditto that’s already wrapped in [! !]?
            • 10449
            • 956 Posts
            Yes, when nesting snippets (even "indirectly" via chunk), use alternate cache syntax.
              • 12556
              • 103 Posts
              I’ll remember that. Thanks!