Since version 1.5, this hasn't been much of an issue, as that release introduced a rule in the mobs' AI to avoid rails unless they are chasing after the player. Although I have still found Zombie Pigmen appearing on the tracks, this is now not as much of an issue as it was in previous versions.
Zombie Pigmen are able to spawn on rail tracks, so removing the walking path on the side will do nothing. But as has been mentioned, adding blocks above your tracks will prevent them from spawning and help keep them from walking onto your tracks 100% of the time. This is a common "fix", and has been around for quite a while, and it doesn't seem like the developers have any plans to stop this fix from being possible.
The following blocks can safely be placed above the tracks, and will not suffocate you:
- Glass panes (I would really recommend this one, since they are "cheaper" than glass blocks, works with stained glass panes as well)
- Glass blocks (works with stained glass as well)
- Glowstone blocks
- Leaf blocks
- Iron bars
- Fences (of all materials)
- Half-slabs (of all materials, note that they must be single, NOT double slabs)
- Stairs (of all materials)
- Trap doors
- Pistons (both extended and retracted)
There are other blocks that would work, such as Beds, Chests, TNT, or Enchantment Tables, but I have excluded them from the list due to being impractical.
The answer you are looking for is hidden inside you own question: "there are a lot outside". The game randomly checks places to put mobs and since the outside is much larger than your trap, most of the zombie pigmen spawn there. The mob limit is exhausted pretty much instantly and the game doesn't spawn any more, unless some of the existing mobs de-spawn or get killed.
You will get zombie pigmen to spawn in your trap eventually, but you may have to wait hours for just a few spawns. You need to prevent spawning outside your trap to improve rates of your trap. This is very difficult to do in the nether, since you can't use light or water to prevent spawning. That is why you don't see zombie pigmen traps, building one is a monumental project. Notice for example here a huge area is covered with half-slabs to prevent spawning.
The spawnable area is +/- 8 chunks from each chunk where there is a player (minus the chunks on the edges of that area). If a single player is online, mobs spawn in 240x240 blocks area centered on the player chunk, that is roughly +/- 120 blocks from the player.
Best Answer
Exactly nothing changes whether Zombie Pigman spawn from Nether portals.
(Well, apart from turning on Peaceful, of course.)
Looking at the code for 1.6.2 in MCP, the code for spawning Zombie Pigmen in portals is dead simple, being only 6 lines of code. If the portal block receives a tick, it checks the difficulty against a random number and if successful, tries to spawn a Zombie Pigman with its feet inside the portal block. It does a check to make sure there is headroom and a solid block under the Pigman's feet, which is why they only spawn with their feet inside the two lower portal blocks inside the frame.
That's it. Light level, player location, and the number of Zombie Pigmen nearby aren't consulted at all.
That means that, so long as the portal is active and in a loaded chunk, it will spawn Zombie Pigmen. By implication, the only way to stop them from spawning is to to deactivate the portal so there are no portal blocks to receive ticks, or to go far away from the portal so the game unloads the chunk it's in.
Further implications:
One method of Zombie Pigmen control that leverages the limited spawning area would be to put doors or fence gates flush against one side of the portal where you normally enter it, and a waterfall at the level of the bottom frame on the other side. This will transport Zombie Pigmen into a holding area where you can dispose of them at your leisure, leaving your portal free for use. If there are any Zombie Pigmen standing in the portal when you want to use it because they haven't gone for a swim yet, you can just gently nudge them into the water flow as you pass through.