OK so to get this done there needs to be two new features. The first is units that are not necessarily square, for example 1x3. The second would probably be the ability of two units to merge together. In this way, two adjascent wall units could join and become one.
There would be different types of wall parts. Three basic types though:
1) A connecing part, it doesn't do anything special except link the other two together.
2) An attacking one that attacks like any other type. Please note that this should be the only one that needs to be distroyed. If distroyed, both the gates and the connecting pieces are too. For example below the a's stand for attacking pieces, g's stand for gates, and numbers stand for connectors.
a12a34g56a78a
If the first attacker were distroyed, then connectors 1 and 2 would be as well. But if the second attacker were distroyed, then numbers 1 through 6 and the gate would also be.
3) Gates would keep creeps out of your town, but would immediately allow any other unit through, whether it be enemy or friendly.