2018.1

Table Of Contents
Targeting elements in a cloned section
Clones that have a unique name can be further personalized with the use of CSS style sheets
(see "Styling and formatting" on page614) and personalization scripts (see "Variable Data" on
page669 and "Writing your own scripts" on page689).
The selector to use is: [section="name of the clone"].
The following CSS style rules target the <h1> element in a number of clones and assign the
respective text a different color:
[section="my_section_clone_0"] h1 { color: red; }
[section="my_section_clone_1"] h1 { color: green; }
[section="my_section_clone_2"] h1 { color: blue; }
The same selector could be used in personalization scripts:
Selector: [section="my_section_clone_0"] h1
Script: results.css('color','red');
Inside a template script, cloned sections can be found using merge.section:
if (merge.section == "my_section_clone_0") {
results.html("Clone!");
} else {
results.html("Original.");
}
Note that in a Control Script, merge.section is only defined when the output channel is WEB;
see "merge" on page1083.
Examples
Cloning a section based on the number of records in a detail table
This script creates as many clones of a section as there are records in a detail table. It assigns
the new sections a unique name.
var printSections = merge.template.contexts.PRINT.sections;
var numClones = record.tables['detail'].length;
for( var i = 0; i < numClones; i++){
var clone = printSections["Section 1"].clone();
clone.name = "my_section_clone_" + i;
Page 722