[development] low hanging fruit for Drupal 6: variable defaults

Robin Monks robin at civicspacelabs.org
Thu May 3 18:29:32 UTC 2007

Variable relms/namespaces++

New names for variable functions--

Variable registry with defaults in a DB--

Variable defaults in hooks+- (not sure)

This is MHO.


On 5/3/07, Gabor Hojtsy <gabor at hojtsy.hu> wrote:
> Hi,
> To be able to translate variables to multiple languages in Drupal
> nicely, we would need a small conceptual change, which would benefit all
> of the Drupal developers, so I am posting the call here in hopes we have
> someone or a small group to pick this task up.
> **We need a central place to define variable defaults**
> Simple! Now whenever you need a variable, you do
>    variable_get('my_fine_var', 'my_default_value');
> The problem with this is that you need to repeat this multiple times,
> and of course there is a chance you need to modify it later on, so you
> need to find all places a variable is used. Not good. Remember the
> changes from bluemarine to garland, we have been fixing theme_default
> errors for days, finding out places where the variable was used...
> So we need a central place to define variable defaults. For Drupal 6
> this is enough now:
>    hook_settings() {
>      return array(
>        'my_fine_var' => 'my_default_value',
>      );
>    }
> Have fun with naming it hook_settings(), as far as I see, it is an
> appropriate name, and not taken at the moment :) So Drupal can do a
> module_invoke_all() on hook_settings() and collect defaults to all
> variables from the modules defining them. It gets easier and shorter to
> use variables:
>    variable_get('my_fine_var');
> We can either cache the default vars as returned by the callback in the
> variable_get() function, or in the database among other variables, you
> get the idea. It is important to have all variables defined in
> hook_settings(), even if the default value is an empty string or array.
> Don't care yet about how this fits into translatable variables, because
> we can only follow up on that if this gets done. So someone please grab
> this issue and run with it ;)
> Gabor

Robin Monks
@ www.civicspacelabs.org
@ www.gmking.org

Fax: (419) 791-8076

"Some people, when confronted with a problem, think "I know, I'll use
regular expressions." Now they have two problems." ~IRC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20070503/f95d203d/attachment.htm 

More information about the development mailing list