Documentation Center

Step 3: Modifying the Page Template to display Component Presentations instead of hardcoded content

If you followed the Quick Guide to creating a Component Template, you have now created a Schema, one or more Components, and a Component Template. Together, you can use these to create Component Presentations: publishable pieces of content you include on your Page. You can now remove the hardcoded contents of your Web page, still present in your Page Template source code, and replace them with instructions to render the Component Presentations on the Page instead.

Procedure

  1. In Content Manager Explorer, navigate to the Folder Building Blocks\System\Template Building Blocks\Design and open the Template Building Block called "Page Template Design" in this location.
  2. In the dialog that opens, select the Source tab.
  3. Find the sections called article, which contain the hardcoded content, and replace them with the following:
    <!-- TemplateBeginRepeat name="Components" -->
      @@RenderComponentPresentation()@@
    <!-- TemplateEndRepeat -->

    This code loops through the list of Components specified for the Page you are rendering, and renders each Component with its associated Component Template to produce a set of Component Presentations.

  4. Save and close your Template Building Block.
  5. Navigate to the Folder Building Blocks\System\Template Building Blocks\Design\images\ and delete the Multimedia Components called "example" and "trex"; they were only in use by the article sections you removed.
  6. Go to the root Structure Group, open "Test Page" and in the dialog that opens, select the Component Presentations tab.
  7. Use the Insert button to add one or more Component-Component Template pairs to the Page.
  8. In the Home Ribbon tab, select Preview to preview how the Page will look, rendered with the Page Template "Main". You should see your rendered Components, rather than your hardcoded content.