We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39521
    • 15 Posts
    This is probably a really stupid question.. but can you only run the runSnippet once?

    I'm working on a secure URL processor and have the following code:

    		$string = array( 	'email' => $this->form['emailaddress'],
    							'code'	=> $_SESSION['CODE'],
    							'eventid' => $_SESSION['EVENTID'] );
    		$reversed = array_reverse( $string );
    
    		$data = array();
    		$data['viewonlinelink'] = $this->modx->runSnippet( 'urlConverter', array(
    												'action' => 'encrypt',
    												'string' => http_build_query( $string ) ) );
    		$data['confirmonline']  = $this->modx->runSnippet( 'urlConverter', array(
    												'action' => 'encrypt',
    												'string' => http_build_query( $reversed ) ) );


    I make two calls to the same Snippet 'urlConverter' which fails.

    If I comment out one or the other call to the snippet it works.. which leads me to assume I can only call that snippet once per page load. Is there anyway around that?
      • 33968
      • 863 Posts
      What's in urlConverter? Are you declaring a function or class in there that might cause a failure when repeated?

      Anything in the error log?
        • 3749
        • 24,544 Posts
        Any functions in urlConverter would have to be wrapped like this to make multiple calls in the same snippet:

        if ( !function_exists('SOME_FUNCTION')) {
            function SOME_FUNCTION () {
                // code
            }
        } 





        ------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using.
        MODX info for everyone: http://bobsguides.com/modx.html
          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