If you think about what you are asking then it becomes clear than no solution can provide the answer you need depending on the two different criteria you propose. If the footer is present then you account for it. If it is not present then you have to remove the method that you were using to account for it.;)
It seems you are using a fixed footer at the bottom of the viewport which means that content will go behind the footer and in order to see it you will need to add a buffer to the last element on the page so that you can scroll the content into view and above your fixed footer.
Usually you would do this with some simple bottom padding on your parent container but the amount of padding of course has to match the height of your footer so in fact fixed (or even sticky) footers are absolutely no use when the footer height is a variable and therefore should not be used.
Fixed footers are best for a fixed height non changing element (like a small copyright message or sitemap link). Otherwise just use a normal footer and avoid the issue altogether.
If some of your pages have the footer and some don't then just add a class to the body tag on the pages without the footer and remove the extra padding from the element that you are using.
However I don't see a problem in leaving an extra 50 pixels of padding or so on the bottom anyway as no one will complain
If your footer is a very tall then it shouldn't be a fixed footer in the first place and a regular footer used instead.
Hope that's of some use.