Quote from: vhollo at Aug 08, 2008, 08:03 PM
When I try it MODx drops an error like it was defined two times.
The first time is line 13 where it actually starts.
The second is line 18 (simple function
) where the trailing } is.
if (!function_exists('function_in_question')) // note: Just the name in single quotes here.
{
function function_in_question(...)
{
...
}
}
Thanks, Bob! That helped.
Is it that the snippet gets part of the program (a class or what?) and when it is used two times on a page the second time the function already exists, right?
Quote from: vhollo at Aug 09, 2008, 04:14 AM
Thanks, Bob! That helped.
Is it that the snippet gets part of the program (a class or what?) and when it is used two times on a page the second time the function already exists, right?
Right. The second snippet call loads the function again and the re-definition causes the error. Another (often better) solution is to create a class, put the functions in the class file and use include_once for the class file.