Cor Bosman wrote:
On Sep 14, 2013, at 11:49 AM, Thomas Bruederli thomas@roundcube.net wrote:
Cor Bosman wrote:
Hey all, I'm wondering if there are some docs that explain how to create a new tab for preferences, where if you click on the tab, you get a listbox where multiple plugins could register for a row. Basically imitating how the settings-tab works. Ideally the plugins would not have to worry about the tab, but could just register their own section on that tab.
For creating a new tab, use the container object named "tabs" to append content either using PHP or javascript. Look at existing plugins such as managesieve [1] or passwords [2].
The general settings tab already provides a hook to add more section: 'preferences_sections_list' [3].
If I understood correctly you want to add another tab that would offer a similar hook for plugins to register settings? This doesn't make sense to me because that already exists.
It exists under 'general'. But ive got about 7 plugins dealing with internal spam/virus settings. Some have their own tab, some are in general. Think spamfilter settings, virus filter on/off, whitelists, blacklists, etc. I want to consolidate all these plugins under 1 new tab named 'Spam/Virus settings' or whatever (under larry this is much more useful than under classic, as larry has plenty of vertical space for 'tabs'). I think this is more logical than having a 'turn spamfilter on' setting under 'general', but a whitelist editor under its own tab.
I can create a tab, no problem. Many of my plugins do that :)
I can create a new section under general, no problem.
But I want pluggable sections under a new tab :)
Understood.
Anyways, what im doing now is i made a plugin that creates a new tab, and has a hook where plugins can register for a section. This works fine. Im seeing a set of plugins. But then I also have to make my own preferences_list and preferences_save unfortunately. Unless there is some trick im missing on how i could re-use those settings functions.
You could make your plugin hook into the 'preferences_sections_list' and 'preferences_list' hooks and re-arrange the items that have been added by the plugins you want to gather. Just make sure your plugin is loaded "after" the others that should make it receive the hook events at the end.
~Thomas