Where to place template code and how to add the template integration?

You’re mixing the old template integration with the new one. Stick to the new format listed in the docs, not posts on the forums