Fatal error: Call to undefined function THAT IS defined in template.php? -Drupal 6.1

pegleglax - March 22, 2008 - 18:32
Project:Drupal
Version:6.1
Component:theme system
Category:bug report
Priority:minor
Assigned:Unassigned
Status:by design
Description

Hi everyone and thanks - I'll make this short,

I'm using a fresh install of Drupal 6.1 with few modules (as i will list below). I made a function in template.php which returns a string:

<?php
function signature() {
    return    
'<div id="signature"><script type="text/javascript">
            var so = new SWFObject("files/swf/sig.swf", "mymovie", "190", "57", "8", "#000000");
            so.addParam("quality", "high");
            so.addParam("wmode", "transparent");
            so.addParam("menu", "false");
            so.write("signature");
            </script></div>'
;
}
?>

When I call that function...

<?php print signature(); ?>

...and display the page logged in as USER #1, everything is normal. HOWEVER, when not logged in as user #1 the page stops parsing and displays...

Fatal error: Call to undefined function signature() in C:\wamp\www\activize\includes\common.inc(1537) : eval()'d code on line 19

...which is a headache.

Any suggestions as to what this may be?

#1

dmitrig01 - March 22, 2008 - 18:40
Priority:critical» minor
Status:active» by design

There is a high likelyhood that the code is being called before template.php is included. Try making a module, enabling it, and putting the function in that module.

And, this is DEFINATELY not critical.

#2

pegleglax - March 22, 2008 - 19:06

Sorry 'bout that dmitrig01,

Thanks for your response! I think functions defined in template.php are definitely called before files like page.tpl.php however as per my experience you cannot use those functions if embedding php in a node.

What'cha think? Anyone else have a workaround for this issue? Possibly a module that implements require_once ('.../template.php'); at the "front of the line"?

 
 

Drupal is a registered trademark of Dries Buytaert.