Update templates.php

ensure $positions is always an array by casting $positions['position'], which isn't an array when returns a single value