So, I use a function called mytheme_number_years_exist() in my template.php to figure out how long an organization has been around. The code itself works fine; I used it in a block and decided to make it a function that I can use in multiple parts of my site. So I made it a function, plopped it into the block, it worked fine and so I put it into my page. But on the page the damn thing gives me the error

[Fri May 30 12:09:44 2008] [error] PHP Fatal error: Call to undefined function mytheme_number_years_exist() in .../common.inc : eval()'d code on line 1

I'm bewildered. I can't figure out why it can't fine my function the template.php. Anyone have any thoughts?

Comments

pog-wmt’s picture

Project: PHPTemplate » Drupal core
Version: master » 5.7
Component: Code » other

bump and reclassification since i'm not positive it's a PHPtemplate problem.

attentat’s picture

Status: Active » Closed (fixed)

found a workaround

Anonymous’s picture

Category: bug » support

I was going to suggest you create a module for the function. Just for documentation purposes; what was the work around?

attentat’s picture

Status: Closed (fixed) » Closed (works as designed)

I asked a question on the forum, and GPK explained that the theme (which is where template.php is) isn't initialized until the bottom of index.php. The workaround was to call the init_theme() function from my node, before I call my function from template.php. Works great.