This is going to sound REALLY SILLY Catjane, but here are a few of the ways I trained them.
Firstly, I kept them in for 2 months when I first got them from the rescue. Polly was a feral, and Sam a semi-feral, so they needed to strongly bond to me and the house. During this time P was untouchable, but I spoke to them lots. One of the things I said was (pointing to some commotion outside, like a noisy car) "nasty!" (in a horrid voice, and pulling a disgusted, about to be sick, face.)
Secondly, if one of them follows me out the front when I'm putting out the rubbish etc, I coax them into the house by shaking munchies, THEN GIVE THEM HELL! I shout BAD CAT! (Clapping my hands and hitting the air with a newspaper, ) and several other expletives in a voice that would raise the dead: raise the volume but lower the pitch, it's really effective, I call it my 'Sergeant Major' voice. Then I'll point to the cat flap which leads to the garden and tell them, in a soft voice, that if they want to go out, that's the way.
I often repeat the NASTY! thing when a lorry goes past, or students are rowdy. This has made them terrified of what goes on out there. The only thing they really know about is that when I take them out there it's in a horrid cage on the way to the vet!
This is much easier in a victorian terrace, such as mine, as there is a definite divide between front and back. Also, the woman who lives next to the passage leading to the front has cats and has put meshing on the bottom of the security gate to prevent them going underneath.
Oh, the problem with the dash outside. Do you have a hallway that you walk into from the front door which has a door into two rooms: your front room, and your lounge? Or do you have a through lounge? Mine is the former, as the front room was a bedroom in my landlady days. If you have the same layout, KEEP THE DOOR LEADING INTO THIS HALLWAY CLOSED!
One evening I went out with a boyfriend and left that door open. I came home to find a frightened cat and poop. She'd shut herself in. When I'd left, she'd gone into the hallway and tried to get out again by pushing the door, which closed it. She was shut in there for about three hours. Poor puss.
It's also best to try to keep your cat/s in the back part of the house.
I hope this makes sense and helps.