We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40045
    • 534 Posts
    OK, I just tried to embed multiple Videos and I get the error "Fatal error: Call to undefined function getIdFromUrl()" ... lol... I read above about the error if you don’t have the if statement before the function, I can also reproduce that, gives me: "Fatal error: Cannot redeclare getidfromurl()" without the
    if ( ! function_exists( 'getIdFromUrl' ) ) {}


    so I implemented this one and now it looks like this, but I get the above "Call to undefined func..." error...wtf...I also tried
    if( ! defined('getIdFromUrl')) { }
    from the post above, but this didn’t change anything...still geht the "call to undefined func" error

    if ( ! function_exists( 'getIdFromUrl' ) ) {
      	function getIdFromUrl($url) {
    		$url_parts = parse_url($url);
    		parse_str($url_parts['query']);
    		if(isset($v)) {
    			return $v;	
    		} else {
    			return false;   
    		}
    	}
    }


    what is wrong with that??

    I also took the whole Snippet code above and copied it into my snippet but it gave me the exact same errors...I don’t get it...any ideas?

    thanks for any advice!

    EDIT: Really strange but I got it...I just moved the whole function from the bottom to the top of the snippet code...now it works^^
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Keep in mind that snippets, unlike include directives or ordinary inline <?php ... ?> tags, are processed through the PHP eval() function. While for the most part there won’t be any noticeable difference, every now and then it does make a big difference due to different scope and code parsing order.
        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