Fixed a bug when changing template of a page