Hi,
While trying to tweak things on the Coppermine codebase as little as possible, as well as keeping themes as they are, I'm trying to move all my mods into a simple collection of plugins. Some changes are really as simple as a couple of PHP lines nevertheless, every time I need to upgrade Coppermine, it's a pain to figure out where things are. Also, tweaking
template.html or
theme.php is not always a good idea, since (the default) themes also get updated every time Coppermine gets an update...
One simple issue I've got is that I need to add some external Javascript (possibly not on all pages). The simplest way to do so is, of course, to hack
template.html, but, as said, this can be a pain for some themes even if I do the changes from within a plugin, this can fail for some themes.
The manual which seems to reflect the yet-unreleased 1.5 version
only suggests that
the $JS variable should be used inside plugins instead, and call the
page_start hook to get it done:
$thisplugin->add_action('page_start','add_javascript');
function add_javascript()
{
global $JS; // Don't forget to make that variable global when using from inside functions
$JS['includes'][] = 'one-external-javascript-file.js';
$JS['includes'][] = 'another-external-javascript-file.js';
[...]
}
Sadly, this gets completely ignored by Coppermine 1.4.X. Probably it's only functional in 1.5, I don't know.
Some plugins use a different hook, either
gallery_header or
gallery_footer instead. This, however, will not place your Javascript inside the <head>...</head> section, but below <body>, somewhere where the
template.html defines where the actual gallery code is supposed to start.
So, how do you include external JavaScript files in Coppermine 1.4.X inside the header? The answer doesn't seem to be "use
js_include" as many have suggested in this forum; at least for 1.4.25, this will fail with an error.