Template Layout

Date: 23-04-2007 14:15 Views: 1552

Other than HTML, MonkeyCMS provides functions and universal variables for you to display your site content. Each template can be made up of any of these and this allows you to display your site in any layout or design you wish. Any non-HTML element must be given it's own line in a template.

Functions
Functions are usually defined by parenthesis () around the function name and any parameters. For example, the template function looks like:

(template|TemplateName)

The function and each parameter is separated by a pipe (|). A full list of functions is available over on the right of any Documentation page.

Universal Variables
Universal Variables are usually defined by curly parenthesis {} and allow you to call variables defined within your skin - this may be a string of text that you would like to be identical on each page, or even an image such as your site logo. There are no parameters for a Universal Variable. An example would be:

{logo}

Content
Your content is the thing that makes your site worth visiting. Some content is displayed through Functions as described above, while other content is displayed directly. Content is defined by square parenthesis []. There are two parameters which can be passed in with content - the first is a flag to force HTML (including line breaks) to be removed from the content, the second is a limit on the number of characters displayed. Both of these parameters are optional. An example of how to display your content title is:

[title]

If you would like to display a block of text without any HTML that may be included within it, you would use:

[content|1]

If you would like to remove all HTML and limit the content to 250 characters, you would use:

[content|1|250]

If you want HTML to be included then it is OK to leave the middle parameter blank like this:

[content||250]

In-line PHP
In some cases you may wish to use PHP to carry out more advanced functions. In-line PHP is defined by including two 'percent' characters %%. All of the PHP code should be included on one line. A simple PHP example is shown below:

%% global $strHTMLOutput; $strHTMLOutput=$strHTMLOutput."SomeText"; } %%

Note the use of the variable - this is the buffer containing your page. Each page is built in memory before it is sent to the browser so you should add anything you want to the page your displaying should be added to this buffer as above.