Include

The Include tag inserts the referenced presentation template code in the current presentation template item. The second presentation template can be referenced only by a path (templatepath).

Like a server-side include, the Include tag is used most often to display headers, footers, and other kinds of reusable content within a page. Using the Include tag ensures that reused content appears uniformly across pages, and it simplifies changes: you only modify the included template file instead of every template page that uses it.

Included presentation templates can be thought of as being cut and pasted into the current presentation template. When the template is run, you can access the item that is being published from an included template as though it were the main template for that item.

One way to use headers and footers is to put all of the formatting and layout information in the header and footer, and the main template simply deals with filling in one cell of a table. For example, if you extracted the commented sections into three presentation templates, then you could use several different types of items for the Main Item template as in the following example:

<!-- Start Included Header template: -->
<html>
<head><title><pcs:value expr="item.title &or; item.name"></pc:value></title></head>
<body>
   <table border="1" height="100%">
       <tr>
           <td colspan="2">Fill with Top Banner content</td>
       </tr>
       <tr>
           <td width="10%">Fill with left hand navigation</td>
           <td width="90%" align="left" valign="top">
<!-- End Header Template -->

 <!-- Start Main Item Template -->
<pcs:include templatepath="ArticleHeader"><h1>Missing ArticleHeader!</h1></pcs:include>
<h1><pcs:value expr="headline">HEADLINE</pcs:value></h1>
<p><pcs:value expr="body">BODY</pcs:value>
<pcs:include templatepath="ArticleFooter"><h1>Missing ArticleFooter!</h1></pcs:include>
<!-- End Main Item Template -->

 <!-- Start Included Footer Template -->
          </td>
       </tr>
       <tr><td colspan="2">The Page Footer goes here</td></tr>
   </table>
</body>
</html>
<!-- End Included Footer Template -->

If you want to display a message if the template is not found, type it in the Text if INCLUDE fails box. (This text appears between the opening and closing <pcs> tags in the PCS Tag box.)

Attribute

Description  
Syntax <pcs:include templatepath="path">default text</pcs:include>

Example

<pcs:include templatepath="/includes/footer">Copyright 2004</pcs:include>

If the specified template cannot be accessed, the include fails and the element's content is evaluated instead. In this example, "Copyright 2004" would display.