How to create Reusable Content

Topics: General, XSLT
Jul 29, 2011 at 2:31 PM

Hi,

How do we create reusable content in composite c1 which will be used across all the pages.

For example, header and footer html contents will be stored in an shared location and which will be used in the template files. In that case I can give access to someone who can change the header and footer without changing the template.

Please help me on this.

Thanks

Kishore

Coordinator
Jul 29, 2011 at 3:00 PM
Edited Jul 29, 2011 at 3:01 PM

Hello,

XSLT functions play a key role in designing and developing websites in C1 and can be used to create reusable content like Header/Footer.

Below is an quick example:

1. Create XSLT, e.g. named "Layout.Footer": Functions -> XSLT functions -> right click -> Add XSLT function -> specify Namespace="Layout", Name="Footer" -> on the Template tab create some output:

 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:in="http://www.composite.net/ns/transformation/input/1.0" xmlns:lang="http://www.composite.net/ns/localization/1.0" xmlns:f="http://www.composite.net/ns/function/1.0" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="xsl in lang f">
  <xsl:template match="/">
    <html>
      <head>
	<!-- markup placed here will be shown in the head section of the rendered page --></head>
      <body>
        <div id="footer">
          <p>Shared content here...</p>
        </div>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

-> Save XSLT ->

2. Go to Layout  perspective -> locate some page template -> edit -> put XSLT function call to the Markup  (Insert -> Function Markup -> select Layout.Footer function ) -> You are done!