We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3610
    • 1 Posts
    Hi There,

    I’m having an global set of functions / classes / settings, which i want to run, before a snippet is called.
    I’ve made a plug-in which loads all these funcs/classes and settings and tried several system-events however none is actually working for me. Even a simple "die" doesn’t display.

    Isn’t this possible the way i’m trying.? ( it should render if the webpage loads, not the manager ).

    Ofcourse i could also add a line to every snippet in which i need these classes / funcs etc but i thought it would be cleaner to do it by a plugin.

    If you can.. please enlighten me smiley

      • 26903
      • 1,336 Posts
      Hmm, I’ve just done a little test plugin that does this :-
      define ('THIS_IS_ONE',1);
      $testtext = 'This is a test string';
      return;
      


      attached to system event OnParseDocument

      I’ve written a little snippet that prints these out in the content of a document, I get this :-

      This is one is :- 1
      Test text is :-

      even if I use global $testtext in the snippet, so the constant stays in scope, the variable doesn’t.

      I think you’d be better including your common stuff at the top of your snippet calls with require_once, I think these effects are seen as a combination of how the core does things and the eval() function.

        Use MODx, or the cat gets it!