Problem with phptemplate.php function calls.

tritao - June 26, 2009 - 10:21
Project:Content Templates (Contemplate)
Version:6.x-1.1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

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.

#1

a.luiz.n - September 8, 2009 - 20:36

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?

#2

a.luiz.n - September 10, 2009 - 20:32

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.

 
 

Drupal is a registered trademark of Dries Buytaert.