[drupal-devel] [feature] Enhance hook_settings - add an optional 'advanced' tab

Crell drupal-devel at drupal.org
Sun Sep 11 06:10:07 UTC 2005


Issue status update for 
http://drupal.org/node/30515
Post a follow up: 
http://drupal.org/project/comments/add/30515

 Project:      Drupal
 Version:      cvs
 Component:    system.module
 Category:     feature requests
 Priority:     normal
 Assigned to:  moshe weitzman
 Reported by:  moshe weitzman
 Updated by:   Crell
 Status:       patch (code needs review)

This was discussed recently on the -devel mailing list, and for reasons
discussed there I have to -1 this in concept.  An "Advanced" tab means
the UI designer failed to properly design the UI to discourage the user
from doing stupid things.  That's not something we should encourage.


If there are too many configuration options in some module for them to
be just shown linearly (I don't actually know many modules with that
problem), that's what <fieldset> is for.  


If some module has enough options that even <fieldset> isn't enough,
then rather than hard-coding an "advanced" tab we should allow
arbitrary module-developer-defined tabs that all get the extra magic of
the settings page.  The $delta methodology of hook_block() would be a
good model to follow here.


If you just want to split some options off as "Danger, Will Robinson!",
frankly I can't think of any good examples.  Perhaps you could offer
some?




Crell



Previous comments:
------------------------------------------------------------------------

Tue, 06 Sep 2005 16:05:53 +0000 : moshe weitzman

Attachment: http://drupal.org/files/issues/hook_settings.patch (25.19 KB)

This patch opens the door for advanced preferences in Drupal. If you
have sufficient permissions, you will see an *advanced* tab on settings
pages when a module chooses to put stuff there. The permission is global
across all Drupal - 'access advanced functionality'.


This patch enhances hook_settings so that it accepts a $type parameter.
By default, $type='simple' and everything works as today. If modules
return HTML when $type=advanced, a new tab appears on the settings
page. To see this in action, visit admin/settings/aggregator applying
the patch and after giving yourself the permission above. The patch
appears long only because of whitespace changes. It is a minor change
to all hook_settings() implementations.


This 'advanced tab' paradigm can be used outside hook_settings as well.
Just protect your tab/feature with the permission above. 


Contrib modules will continue to work without patching but will show an
duplicate tab called 'advanced'. To fix, just add an if($type ==
'simple') block in hook_settings(). I will add upgrading instructions
to drupal.org and update hook_settings() docs if this is committed. 


I feel that this is a good balance between those who repeatedly yell
for 'fewer settings' and those who want their site to work a specific
way but are uneager to hack the source code. This 'advanced settings'
paradigm has worked well for Mozilla project (about:config) and many
others. If these advanced features clutter and bother you, don't enable
this permission or don't click on the advanced tab. There is no way that
Drupal becomes a cluttering steaming pile of configuration options - our
culture precludes this. Lighten up, and give the people what they want.
We can't expect everyone to hack the source to get commonly requested
behavior.


I also simplified upload config by renaming upload_admin() to
upload_settings() and removing an unneeded menu entry.




------------------------------------------------------------------------

Sun, 11 Sep 2005 05:28:51 +0000 : moshe weitzman

i'd like to hear some comments from CVS review team on this. If not
desired, alternatives are appreciated.







More information about the drupal-devel mailing list