From The Smartest Wiki
Jump to: navigation, search

Fields are small spaces on the page where fragments of data such as strings, numbers, and other basic values can be inputted by the user via the CMS.

Fields are triggered by a template tag and can either be defined differently on each page, or can be set up as "global" so that they show the same value on every page, and can be edited within the CMS from any page where they appear.

Fields do not contain files, items or any other database content - their values consist only of user input, stored using some of Smartest's basic types.

A field is created by adding the following tag to any container template or page master template:

<?sm:field name="FIELDNAME":?>

The name of the field, here abstracted to "FIELDNAME" should always be lowercase, and composed of letters, numbers and underscores.

Accessing and displaying field data

Since it is the presence of the above template tag that will alert Smartest that there is a field on a given page, and thus make it available to be defined via the appropriate user interface, it will be necessary to have that tag somewhere on your page.

However, you may not want the actual information contained in the field to be displayed at exactly the point in the template where the tag has been added. For convenience, since the coincidence of the tag and the display of the value it contains is a relatively common occurrence, this is still the default behaviour. However, the display of the information at the point where the tag is executed by Smartest can be suppressed by adding the display="false":

<?sm:field name="example" display="false":?>

Conversely, there may be places in a template where you wish to access or display the value of a field. Since the <?sm:field name="example":?> tag should only be used one per field on any given page, you should not use the tag again for each access or display of the field's value. There are several equivalent ways to do this:


Storing data in fields

Fields do not contain files, items or the any other database content, including primary keys - their values consist only of user input, stored using some of Smartest's basic types: