CMS Template

Site Template and Pages

EduBrite provides default template for rendering all CMS pages. The default template is customizable to some extent using the properties of the page. But to fully control the page layout, you can create custom template using Velocity scripting language.

To create your first template, use Site Admin->CMS->Create New->Site Template. Let's call this template, helloTemplate and save it.

Enter following content in template to start with.

<html>
  <head>
    <title> $ctx.get("viewData").getDescriptor().getTitle() </title>
  </head>    
  <body>
    $ctx.get("viewData").getRawContent()   
  </body>    
</html>

In the above code let's look at highlighted lines. These lines are example of Velocity script code that adds the title and content of the page, on which the template is applied, in the output. The indicate our template to be using Velocity scripting, we need to specify a template property. So open the properties of the above template and enter velocity in the IMPL_TYPE property.

Next, we can create a Site Page and add just a simple "Hello World" as the content. From the properties of the page, we can add Title and mention the name of the template we want to use to display the page. (If you don't mention the template, a default template will be used that will maintain your site's look n feel and show the page content).

Save your changes and publish the site from Site Admin->CMS. Click the view icon in cms browser list to view the page99 . Here is how it looks.

So you can see that our page's content has been rendered by the template. You can repeat the page creation steps and create more pages and specify helloTemplate to be the renderer for those pages, just for fun.

So far we saw a very basic template and how its used while viewing a page. The output so far isn't that great, but we learned an important concept for using the CMS.

Next, lets work more and make our template a bit more powerful.

 

 


Rating: