Bugzilla:Extension Notes: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 53: Line 53:


As well as using the <tt>config_add_panels</tt> hook, you will need a template to define the UI strings for the panel. See the templates in <tt>template/en/default/admin/params</tt> for examples, and put your own template in <tt>template/en/default/admin/params</tt> in your extension's directory.
As well as using the <tt>config_add_panels</tt> hook, you will need a template to define the UI strings for the panel. See the templates in <tt>template/en/default/admin/params</tt> for examples, and put your own template in <tt>template/en/default/admin/params</tt> in your extension's directory.
==Adding User Preferences==
To add a new user preference:
* Call <tt>add_setting('setting_name', ['some_option', 'another_option'], 'some_option')</tt> in the <tt>install_before_final_checks</tt> hook. (The last parameter is the name of the option which should be the default.)
* Add descriptions for the identifiers for your setting and choices (setting_name, some_option etc.) to the hash defined in <tt>global/setting-descs.none.tmpl</tt>. Do this in a hook: <tt>hook/global/setting-descs-settings.none.tmpl</tt>. Your code can see the hash variable; just set more members in it.
* To change behaviour based on the setting, reference it in templates using <tt>[% user.settings.setting_name.value %]</tt>. Reference it in code using <tt>$user->settings->{'setting_name'}->{'value'}</tt>. The value will be one of the option tag names (e.g. some_option).
Account confirmers, Anti-spam team, Confirmed users, Bureaucrats and Sysops emeriti
4,925

edits