Iterating regions in Dreamweaver templates

Having extracted all component presentations into package variables with the Extract Components from Regions template building block, we can work with them in Dreamweaver page design.

I doubt Dreamweaver page templates are widely used, so I put here some samples just in case somebody will need them.

 

Checking if page contains any regions

If page has at least one region, package will contain the PageRegions variable:

<!-- TemplateBeginIf cond="CollectionLength('PageRegions') > 0" -->
  <p>Page contains @@CollectionLength('PageRegions')@@ region(s).
<!-- TemplateEndIf -->

 

Checking if particular region exist on the page

The "Extract Components from Regions" Template Building Block adds variable named as fully-qualified region name:

<!-- TemplateBeginIf cond="'Hero'" -->
  <p>The 'Hero' region contains @@CollectionLength('Hero')@@ Component Presentation(s).
<!-- TemplateEndIf -->

 

Iterating over Component presentations in the specific region

Variable with fully-qualified region name contains list of component presentations in this region:

<!-- TemplateBeginRepeat name="Extras\Related" -->
  <div>@@RenderComponentPresentation()@@</div>
<!-- TemplateEndRepeat -->

 

Iterating over Component presentations in all regions on the page

Variable PageRegions contains list of fully-qualified names of all regions on the page. Outer loop iterates over this collection. As package contains separate variable named after region's fully-qualified name with all component presentations, add an inner loop that will iterate over CPs in each region (@@Value@@" contains fully-qualified region name):

<!-- TemplateBeginRepeat name="PageRegions" -->
  <!-- TemplateBeginRepeat name="@@Value@@" -->
    <div>@@RenderComponentPresentation()@@</div>
  <!-- TemplateEndRepeat -->
<!-- TemplateEndRepeat -->

 

Anonymous