However when the spawner is crafted it's a pig spawner. I've tried a lot of things, mostly copy pasting things because I am not experienced enough to know what I'm actually doing and needless to say it didn't work. I've searched through web pages related to this topic but couldn't find anything useful. I would be really grateful if someone could help me out on this.
If this is for 1.7.10, this cannot be done without custom handlers due to how the game is programmed.
The mob spawner block does not use a custom item block (item that places the block...) or any logic relating to the item's nbt data, so the game doesn't "know" what to spawn, and by default, the mob spawner block is set to be a pig. Dungeons generate mob spawners by setting the block and tile entity, then manually setting the tile entity's spawning entity.
To work around this logic problem:
We could A, edit the game's code when it's loaded by making a coremod. This would be the best method for optimization since it'd only modify the code once and not every single use.
Or B, make an event handler doing the custom logic we need. This is definitely not the best for optimization and will cause lag (not right away, but "eventually").
Option A is a long drawn out process I won't bother explaining or doing. It's not hard.
I've already done Option B for you. Modify as needed.