Iterating regions: "Extract Components from Regions" TBB

Sites 9 comes with one extra default template building block: Extract Components from Regions. If you upgraded your system from previous versions, re-generate default templates by running the Tools->Create Default Building Blocks command in Template Builder.

The new Building Block examines the Page item in the package and finds all regions on the page and processes each region:

  • for each region it places all the Component Presentations in a separate array and then adds this array to the package using region's fully-qualified name as array name;
  • creates an array of all fully-qualified region names and adds this array to the package under "PageRegions" name.

For example, suppose we have following page structure:

After executing Extract Components from Regions TBB, templating package will contain following variables:

Page contains all region names and there is a separate list of CPs for each region:

Note that Components array, as it was in previous versions of SDL Web, contains an array of Component Presentations that are placed directly on the page and does not contain CPs from regions.

Next time I'll show several examples on how to use these variables.