Check out
afterlab's Hide Unentered Fields hack it may be what you are after.
Also, you should consider installing
Logician's Advanced Templates: Dynamic Templates Changing according to different conditions hack - it's a very simple, but very powerful hack that lets you put conditionals in your templates, meaning in many cases you don't have to hack yer php files.