Introduction to Saurus API

Saurus API is extension to Smarty template engine. It extends Smarty syntax with tags specific to Saurus CMS. If you are unfamiliar with Smarty, we recommend to read at least basic syntax before continuing.

Templates

Templates contain both site layout and basic functionality and therefore define the way Saurus CMS presents content from database. Most website templates contain a mix of HTML and Smarty tags but you can also use PHP. In addition to websites, you can write specific templates to output content in virtally any format including XML, RSS, WML and others.

Saurus CMS uses two types of templates to render websites: page- and content templates.

API tags

As all Smarty syntax, Saurus API is written beteen curly brackets.

Variables

Variables start with dollar sign. The following example displays site title defined by user in the software's administrator's environment:

{$meta_title}

Functions retrieving CMS objects

These functions retrieve a list of objects from Saurus CMS database. The following example opens a database query and returns a list of 1st level sections/menu items. Parameter "name" here defines a variable which will hold the array of returned elements. This line of code does not produce any output, it just opens a database query and stores the result.

{init_sections name="section_list" level="1"}

To display the result, you can use various attributes of returned object. Here's how to cycle throught the list of results and display titles of all 1st menu elements:

{init_sections name="section_list" level="1"}
{foreach from=$section_list item="section"}
    {$section->title}<br>
{/foreach}

What next?

A good place to start would be following the tutorial of creating a page template.