in actinic, you can use php to do complex things, we know this, but what happens when you want to define a function?
first of all, you can do it in the actinic_main.php file, but, what if thats not appropriate?
well, if you define a function within a template, actinic accepts it, but then, if you look at the page again, it suddenly decides to throw a wobbler. You cannot define the same function twice in the same session.
PHP does not allow you to 'unset' a function, but luckily, I found a quick workaround:
Voila. The function is created on the first pass, then next time its parsed, actinic skips over the creation.
Hope this helps someone.
first of all, you can do it in the actinic_main.php file, but, what if thats not appropriate?
well, if you define a function within a template, actinic accepts it, but then, if you look at the page again, it suddenly decides to throw a wobbler. You cannot define the same function twice in the same session.
PHP does not allow you to 'unset' a function, but luckily, I found a quick workaround:
PHP Code:
if (!function_exists('myFunc')) {
function myFunc($variable) {
//function here
}
}
Hope this helps someone.
Comment