全部博文(21)
分类: Python/Ruby
2011-07-18 23:10:09
来源:
I've opted for the third method. First I created a file called external-js.tpl.php in my theme directory, containing this:
Then, in my template.php file, I created a pre-process function that loads that into a variable and adds the appropriate JS function call to $footer:
Lastly, I modified page.tpl.php to print the variable $external_js right after $script in the header. I could also have printed it right before the footer, and that might have been better for performance. There's actually a module for Google Analytics already, but it doesn't fit my needs very smoothly (it's designed for single sites, when I'm working with a multi-site install of nearly a hundred distinct Drupals).