You have to set up this also in the script which calls showthread
PHP Code:
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
// get special data templates from the datastore
$specialtemplates = array();
// pre-cache templates used by all actions
$globaltemplates = array();
// pre-cache templates used by specific actions
$actiontemplates = array();
Why ? Because, this need to be setup before global.php is calling. As it's written in your script, you call global.php (require_once mean called once and no more ...) but showthread.php won't call it (as it was already called) ... and $globaltemplates, $phrasegroups etc. won't be loaded.