Added support for the portal modes overriding in the templates