We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3232
    • 380 Posts
    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?
      • 21257 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');
      }
      
      
        Mike Schell
        Lead Developer, MODX Cloud
        Email: [email protected]
        GitHub: https://github.com/netProphET/
        Twitter: @mkschell
        • 3232
        • 380 Posts
        That did the trick. thank you