Use meaning and construction together.
1. Find the action.
2. Ask where did it happen?
3. Identify the word that gives the spatial relation.
4. Check the idafah: the adverb is mudaf and the following noun is mudaf ilayh.
New application:
وَقَفَ الْحَارِسُ قُدَّامَ الْبَابِ
The guard stood in front of the door.
قُدَّامَ answers where, and الْبَابِ completes its meaning.