I have two different snippets that utilize the SimplePie classes (simplepie.org)
The first one is the GoogleEvents snippet in the repository. the other is a custom snippet i am creating.
The problem I am having is these two snippets will appear on pages together and separately. When they appear on the same page, I get a fatal error saying that they can’t redeclare simplepie.
I used include_once in both snippets but it appears to be including the file in both snippets even if it included it previously.
Is there anyway I can call this globally? so that it doesn’t try to redeclare itself?
-
MODX Staff
- 730 Posts
You could try wrapping the snippets’ include statements in a check to see if the class is already defined...
<?php
...
if(!class_exists('simplepie')) {
include_once('simplepie.php');
}
That did the trick. thank you