Skip to main content

Site preferences

Accessing preferences

Site preferences are globally available via $tfPreference, an instance of the TfPreference class set in tfHeader.php, which is included in every page. To access a preference within a controller script you simply call:

$tfPreference->somePreference;

If you want to output a preference to display and need an XSS-escaped version of the value, use:

$tfPreference->getSomePreference();

Editing preferences

Tuskfish preferences are edited via the Preferences link in the admin section of your site. The function of each preference is described in the User Manual.

Adding new preferences

You can add additional preferences to Tuskfish very simply. All you need to do is to:

  • Add another row to the preference table of your database (use phpLiteAdmin or equivalent), with an appropriate data type and value.
  • Add the new preference as a whitelisted property to the TfPreference constructor, for example:
protected $someNewPreference;
  • Add a public setter method eg. setSomeNewPreference(). This should set explicit validation rules to ensure that the preference cannot be misused.
  • Add a public getter method eg. getSomeNewPreference() that outputs an XSS escaped version of the value (see the other getter methods in TfPreference for examples).
  • Add a row for your new preference to the form trust_path/libraries/tuskfish/form/preferenceEdit.html, so that you can edit it from the preference page.
  • Add a language constant for your new preference to trust_path/libraries/tuskfish/language/english.php or equivalent.

Copyright, all rights reserved.

Related

Tuskfish CMS Developer Guide

This guide will give you an overview of the architecture of Tuskfish CMS, how to write code to perform common operations and how to extend the system to suit yourself. The guide accompanies the Tuskfish API documentation. Keep a copy handy as you read this guide. It is best to review links to the API where provided, as not every detail will be discussed in the text. This is the first version of the guide, so it is still a work in progress.