If for some reason you feel that a page template should support 7 different configurations, all similar 1,2,3 columns with and without sidebar etc… Here is how you don’t make your template page:
Do not make an if, else tree with the 7 different options and then cut and paste the same 700 lines for the entire page into every section making a template that is ~5000 lines long.
If that is your thing, first I hate you and wish ill upon you and everyone around you; second don’t be surprised when different configurations make things stop working, and third, buy an object oriented programming book and learn how to write some code.
Lastly, I hate you and wish ill upon you and everyone around you.