How to assign variables to a template

The global template object $tfishTemplate is used to store data for presentation. You can assign data directly to this object like this in your PHP page code:

$tfishTemplate->myName = $someName;

When a template is rendered its properties are extracted and become available as variables. This means you can use them directly by accessing a variable with the same name as the property, ie. $myName in this example.

You can also assign data to sub-templates in a nested set, but the extracted properties have specific scope in that case (they will only be available in the sub-template in which they were set, so the templates must be rendered in sequence). Please see the Developer Guide for information about working with nested templates.

Bear in mind that the template object does not escape data for display. To guard against XSS attacks, you should escape the data in the template.

Since you are the only person uploading content there really shouldn't be any XSS attacks, but it is still good practice in the event that a malicious agent gains access to your site.

Copyright, all rights reserved.

Related

Tuskfish CMS User Manual

The user manual provides a comprehensive guide to Tuskfish CMS operations. It covers all all aspects from installation to adding and curating content, managing site security and customisation of themes. For additional information on how to customise Tuskfish please see the developer guide.