6th June 2012

What are all the possible variable types supported by the variable module?

John Ennew
Technical Director

The variable module provides an alternative to the variable_get and variable_set drupal functions which allows better definition of your variables in a structured manner. Variables your module makes use of can all be declared in a function called hook_variable_info. Here you can describe the default value for each variable and also describe what kind of variable it is, for example "string", "number" etc.

To get a list of all the options of variables on your site you can run the function:


variable_get_type();

To see this quickly as a list on the command line, you can use the following drush command


drush ev 'print_r(array_keys(variable_get_type()))'

This currently returns


Array
(
[0] => menu
[1] => node_type
[2] => text_length
[3] => drupal_path
[4] => file_path
[5] => weekday
[6] => theme
[7] => country
[8] => timezone
[9] => date_type
[10] => date_format
[11] => vocabulary_vid
[12] => vocabulary_name
[13] => user_mail
[14] => array
[15] => boolean
[16] => default
[17] => enable
[18] => multiple
[19] => mail_address
[20] => mail_text
[21] => number
[22] => options
[23] => select
[24] => select_number
[25] => string
[26] => text
[27] => unknown
[28] => url
[29] => mail_part
[30] => text_format
)