Pay attention to your first sentence:
I have created a theme that contains several functions.
The link that you have provided warns about what type of functions hold a
template.php in a theme.
There are two main types of functions in template.php: theme function
overrides and preprocess functions. The template system handles these
two types in very different ways.
Is legendary_views_field_compare_value() any of these cases? OK, we agree that the anwers is No. It's a custom function that you have written.
Why should not you put your custom functions in
Because Drupal has a registry of implemented hooks and templates that have been overriden. The system only load the
template.php when match the hook in the registry. So, the
template.php is not always load.
First of all, you should keep separate the custom functions from the theme functions. You need to create a file called for example
my_custom_functions.inc , and insert all your custom functions in that file.
How do i load a file with custom functions that i need to call in my templates?
To keep separate the logic from the theme functions, i would stored the custom functions in a module. But, it is also possible store the functions in your theme. In both cases, you have to follow the next strategy.
It's really easy. Every time that a template is rendered, a preprocess function is fired by default to let other modules to act. So, it is always fired a preprocess (and process) function before the slideshow.tpl,php. In this moment, we will load the file with our custom functions.
Here an example:
* Implements hook_preprocess_slideshow()
* The file will load before rendering slideshow.tpl.php
Please, pay attention to the name of the template. In my simulation, i have changed the template called
views-slideshow.tpl.php . So, when you implements in hook_preprocess_HOOK(&$vars) , you need to change the hyphens. The result would be
If you have to load the same file with custom functions in lots of templates, you could implement the general
hook_preprocess($vars), that it is always fired. Here an example:
* Implements hook_preprocess()
* The system always load the file