We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10525
    • 247 Posts
    I have created a simple custom snippet which contains two functions.
    When I call the functions from within the snippet I get a blank page. Annoyingly, I can't get any relevant errors, either in a file via MODx or Plesk, or output errors either. Just a blank page.

    I trimmed this down to the smallest snippet which reproduces the issue:
    $return = "TEST-";
    $return .= test();
    
    return $return;
    
    if (!function_exists('test')) {
      function test() {
    		return "test";
      }
    }

    If I comment out line 2 I get the output "TEST-".
    If I don't, I get a blank page.

    Can anyone tell me what I am doing wrong here?

    I am using MODX Revolution 2.2.10-pl (traditional). The last time I did any serious snippet coding was in Evo, so I am having to re-learn an awful lot of stuff!

    edit: same result whether I call the snippet with [[!products]] or with [[products]]. [ed. note: Gav last edited this post 12 years, 9 months ago.]
      • 3749
      • 24,544 Posts
      Move the function to the top of the file. wink

        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 10525
        • 247 Posts
        Quote from: BobRay at Dec 11, 2013, 02:18 PM
        Move the function to the top of the file. wink

        Cheers Bob! So refreshing to make a schoolboy error with a simple solution... smiley
          • 3749
          • 24,544 Posts
          Yes, my favorite kind of error. wink
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting