More robust CMS_TEMPLATE implementation
Merge pull request #2708 from yakky/feature/fix_page_template

More robust CMS_TEMPLATE implementation