Bridgeline Digital Logo
Menu

Content Templates

Content templates enable content authors to create, edit and manage content on your website with clicks, not code.  OrchestraCMS comes with a variety of content templates out of the box, and the Content Template Creator feature for creating additional simple templates.  For any requirements that cannot be met by the out of the box content templates or Content Template Creator, you can extend the functionality of OrchestraCMS by creating your own content template using Salesforce code.  A content template has two base components:

Renderer - An Apex class that provides any logic (e.g. SOQL, apex, callouts, etc.) and the markup that will be rendered on the resulting page of the website.

Content Edit Page - A Visualforce page which provides the content author with an interface they can use to enter the attributes that will be combined with the markup to produce the final rendering of the content on the website.

A record must then be created in the Content Layout object in Salesforce that ties these code elements together as a Content Template.  The name of the Apex class is added to the Contoller field on the Content Layout record and the name of the Visualforce field is added to the Visualforce Edit field.  This will result in a content template appearing in OrchestraCMS Setup | Templates | Content Templates.  The content template still needs to be added to a  Content Type before it can be selected by a content author.

Renderers

A content renderer is an Apex class that outputs a getHTML method used to supply the markup that will be output on a page on the website.  Below is the basic markup of a content renderer.

global virtual with sharing class SampleContentTemplate extends cms.ContentTemplateController {
    global SampleContentTemplate(cms.CreateContentController cc){
        super(cc);
    }
    
    global SampleContentTemplate(){}
    
    public String myAttr{
        get {
            return(this.getProperty('myAttr'));
        }
    }
    
    global virtual override String getHTML() {
        String html = '';
        html += '<div class="myClass">' + myAttr + '</div>';
        return html;
    }
}

Based on the rest of this example, this content renderer would produce the following markup when viewed on the website. This assumes that the myAttr property has a value of 'Hello World':

<div class="myClass">Hello World</div>

Content Edit Pages

The content renderer only provides the base markup for the content.  The content author needs a way to provide the value for myAttr that will be used in the final markup on the website.  This is provided in the form of a content editor page.  An example of a content editor page that references the content renderer class called SampleContentTemplate is shown below.

<apex:page controller="cms.CreateContentController" extensions="SampleContentTemplate" showHeader="false" sidebar="false" cache="false" standardStylesheets="false">
    <script type="text/javascript" language="javascript">
$(document).ready(function() {
    ce.content_editor('registerSaveFunction', function() {
       var attributes = [
           { name: 'myAttr', value: $('#myField').val(), type: 'Text', lang: '' }
       ];
    
       return attributes;
    });
});
    </script>

    My Attribute: <input id="myField" type="text" value="{!myAttr}"/>
</apex:page>

The provided code would give a content author this content editor page when creating content using this template.

Content Layouts

Each content template requires a record to be created in the Content Layouts object in Salesforce.  The screenshot below is a content layout record based on the examples provided.

Content Types 

In order for a content author to select this content template when authoring content, the content template must first be added to a content type.  The template can be added to an existing content type or a new content type.  Content types are accessed through OrchestraCMS Setup | Templates | Content Types.