Yes of course it is, it's under Style Manager ==> Edit Templates. It took me some time to get used to the way the templating is done, but once you do it's very easy to add and edit php code in each part of the template.
I found the solution to my problem.
You can't add php code to a template. What you have to do is create a plugin with your php code to set up the variables that you want to use in your template.