Bridgeline Digital Logo
Menu

Extending the CTC

The Content Template Creator (CTC) is used to create basic static content templates.  Through the GUI it supports only direct markup, not Apex.  If you want to extend content templates created with the CTC using your own custom Apex logic, you can write a custom Apex class and edit the Content Layout record created by the CTC, replacing the value in the Controller field of the record with the name of your custom Apex class.

For example, using the CTC to create the content template, shown below...

...would result in the CTC automatically creating this Content Layout record in Salesforce.

Note that the Visualforce Edit and Controller fields are auto populated with CTC  specific values.  Instead of providing the render markup thorough the CTC interface, an Apex class can be built to support your custom logic.  There are some special considerations when extending a CTC content template with custom Apex.  An example is provided below.

global class myLayout extends cms.CTCLayoutController {
    global override String getHTML() {
        init();
        String myAttr = (String)attributeGenerateValues.get('myAttr');
        return '<div class="myClass">' + myAttr + '</div>';
    }
}

 

  • The class must extend cms.CTCLayoutController
  • The first line of the getHTML method must call init()
  • To support the field validation provided by the CTC you must use attributeGenerateValues.get('attributeName') instead of getProperty

Once the class is created, the Content Layout record needs to be modified.  An example is shown below.