5 February 2018 | 231 views
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:
If you want to output a preference to display and need an XSS-escaped version of the value, use:
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:
- 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.