[development] low hanging fruit for Drupal 6: variable defaults
Gerhard Killesreiter
gerhard at killesreiter.de
Thu May 3 09:00:31 UTC 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Gabor Hojtsy schrieb:
> 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 should however keep an optional second argument. I don't always use
the same second argument, and that's intentional.
Cheers,
Gerhard
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFGOaSvfg6TFvELooQRAkVJAKCxgx8aoZCi+RlFQ6f+Jmde6J3QDQCfSn3v
dD6nu3VJlAmkd7zYcbwS2Tk=
=MxzI
-----END PGP SIGNATURE-----
More information about the development
mailing list