First off, true that expression is useless as it is..
You could make the -if- statement more accurate by adding an else:
Also youll have to make foot something that controls the joints but is not the control itself...
Now think about this.. youll come to the conclusion that this method still is rubbish since it takes in only direct .ty connections rather than evaluating correctly the entire upstream hierarchy for all the involved nodes.
Youll have to do some proper maths here to accomplish what you are looking for. So either compare the world ty (via matrix decomposition or locator shape) of ground closest point and your colliding object. And switch translate inputs through a condition node.
Things will get tricker tho since pushing the foot straight down -y will not account for the length of your toes which will result in strange shifting of your joint. But it will take you a good piece of the way. The rest is down to some research about the proper trigonometric calculatins and correct implementation into maya nodes..