-
MODX Staff
- 10,725 Posts
You’re definitely going to need to provide some code for context or explain more what you are trying to accomplish. MODx does not change PHP, so variable scope behaves normally, though you must remember that modules, snippets, and plugins are executed as eval()’s.
-
MODX Staff
- 10,725 Posts
Again, without context of where this is being run or how, I have no idea where you are expecting this parameter to be available. In snippets, if passed as parameter, or inherited from a module, that should work. But I suspect you are expecting that parameter to be a global variable, and it’s not. It’s local to the scope of the module, and by referencing it using global, you are looking for something outside the current scopes of the function and module itself. I suggest passing the variable to the function. Globals are a bad practice IMHO, and you should avoid them like the plague.
-
☆ A M B ☆
- 24,524 Posts
But don’t forget that if your module uses a function, you have to either pass the variable in the function call, or have a line in the function declaring the variable to be global (global $var).