I am creating a page that should have a ton of custom PHP in it, but also it has a theme that is unlike any other page so I am wondering... is it a bad idea to include all my PHP code as part of the tpl.php? Or should I insert it as content somehow later? Does the JavaScript go in the same place?

I am a bit of a Drupal newb. Thanks for any replies!

Comments

DragoonBoots’s picture

What I've gathered is that the "right way" to do it is to put it in a function in your template.php and call those functions in your tpl.php. However, until relatively recently, Garland (the default theme since Drupal 5.x) still had bits of code in its tpl.php. Personally, I tend to put small things there, such as an if statement to control which theme function runs or to control the output of content, while i'll put larger things, such as formatting something or splitting content in interesting ways, in my tpl.php.

auxone’s picture

Thanks. That sounds logical. Does it still apply if the 'tons of PHP' don't have anything to do with the look of the site? Some of it will, but a lot of it is just information processing. By the same token, I hope JavaScript can be added in the same way. I saw a function that will add scripts to themes, so I guess I'll just use that.