Enable Master Template Switching
Master template switching is a technique you can use to provide editorial staff with a very quick way to switch between different layouts. A typical use case is "instant" reformatting of the front page when a big story breaks. Under normal news conditions a "default" layout gives two or three top stories broadly similar prominence. When a big story breaks, however, editorial staff want to switch to a "breaking news" layout in which much greater prominence is given to the number one story, and less to the other top stories.
Master template switching allows editorial staff to make this kind of change by simply changing a section page option in Content Studio.
To set up master template switching:
-
Create the master templates you want to switch between (say
config.default.master.frontpage.default
andconfig.default.master.frontpage.breaking
). These master templates should contain sets of correctly configured widgets that you have tested in the location where you intend to use them. -
Add a template switching option to one of the groups on the required section page. To do this you have to edit your publication's
layout-group
resource and add a structure something like this:<group name="topStories"> ... <ct:options> <ct:field name="masterconfig" type="enumeration"> <ui:label>Select page layout</ui:label> <ui:description>Master configuration option for the group</ui:description> <ct:enumeration value="frontpage.default"> <ui:label>Default</ui:label> </ct:enumeration> <ct:enumeration value="frontpage.breaking"> <ui:label>Breaking news</ui:label> </ct:enumeration> <ui:value-if-unset>frontpage.default</ui:value-if-unset> </ct:field> </ct:options> ... </group>
The important points about this option definition are:
-
It must be called
masterconfig
. -
It should be an
enumeration
field with oneenumeration
element for each master template that you want to switch between. -
The
value
attributes of theenumeration
elements must either be:-
the names of the master templates you have created, but without their master template prefix (that is,
mymaster
, notconfig.default.master.mymaster
orconfig.mycontentprofile.master.mymaster
), or -
the special keyword
auto
. This causes the Master widget's Master section unique name to be used.
-
See here in the Escenic Content Engine Template Developer Guide for information about the
layout-group
resource and how to edit it. -
-
Add a Master widget to the template used by the section page.
-
Set the following fields in the Master widget:
- Title
-
Set to anything you like.
- Master section unique name
-
Set this to the name of any one of your master templates (for example
config.default.master.frontpage.default
). The template you specify here will get used if:-
The Master widget is used on a section page that has no
masterconfig
option, or -
The user selects an option containing the special keyword
auto
.
-
- Master group name
-
Set this to the name of the section page group to which you added the
masterconfig
option (topStories
in the example shown above) Make sure that you use the name of the group (as specified in thelayout-group
resource) and not its label as displayed in Content Studio. These may be the same, but are not necessarily so.If there are several section page groups with the same name on the page, then you must specify which one you want by appending an index to the name, as follows:
name-index
All the groups are numbered in a single sequence, even if they belong to different areas, and they are numbered from one. So if a section page contains two areas, the first area contains one group called
myGroup
and the second area contains two groups with the same name, then in order to identify the second group in the second area, you would need to specifymyGroup-3
.
Make sure that all the changes you have made are published. You should
now be able to switch between the layouts you have defined by simply
changing the value of the masterconfig
option you
added to the section page and pressing Publish in
Content Studio.