How to hide the header and footer on certain pages

No need to use a condition!
Simply edit the page and change the Default template to:

[Breakdance] No Header / Footer template

No Header Footer Template