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

Aaron Winborn aaron at culturefix.org
Fri May 4 14:56:24 UTC 2007


+1 to this. maybe slightly more complex to set up, but declaring 
variables forces some thought into structure, helps keep them 
centralized in code, easily extensible. of course, this opens up the 
can-of-worms possibility of hook_variables_alter... :P

Larry Garfield wrote:
> hook_variables() {
>   $items = array();
>   $items['mymod_num_things'] = array(
>     '#default_value' => 2,  // Same syntax as FAPI uses
>     '#realm' => 'mymod', // optional
>     '#translatable' => FALSE, // probably default false
>     '#cacheable' => TRUE, // default to TRUE if under X chars when serialized
>     '#serialize' => FALSE, // default to true for object/array, else false 
>   );
>   foreach (node_get_types('name') as $type) {
>     $items['mymod_things_for_' . $type] = array(
>       '#default_value' => array(),  
>     );
>   }
>
>   return $items;
> }
>
>
>   
-------------- next part --------------
A non-text attachment was scrubbed...
Name: aaron.vcf
Type: text/x-vcard
Size: 247 bytes
Desc: not available
Url : http://lists.drupal.org/pipermail/development/attachments/20070504/2cca46e4/attachment.vcf 


More information about the development mailing list