I've noticed that if I call a template.php custom function from inside a contemplate file, it works well on the frontend, but it gives me an undeclared function error when I enter the contemplate backend.

Including template.php in the contemplate file with 'require_once...()' solves it for the backend, but then complains in the frontend, because template.php is already included.

I woudn't want to have to duplicate this functions inside the contemplate file.

Comments

andrenoronha’s picture

that happens because the function inside template.php only works for the custom theme where the file is.

my question is:
is there a way to make it works without having to declare it in the template.php of my admin theme?

andrenoronha’s picture

ok, i got a solution.
before printing the function I checked if it really exists.

if (function_exists('my_function')) {
  my_function();
}

in the backend of contemplate it will do nothing. so no bugs.