Labs

By John Ennew | 6th June 2012

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

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
)

Comments

fndtn357
fndtn357

some days are kind of like "duh", thanks for your response.

fndtn357
fndtn357

using drush 5.4 nd the output gives me : Error: Call to undefined function variable_get_type() in /usr/local/share/drush/commands/core/core.drush.inc(992) : eval()'d code, line 1

what am I doing wrong?

John Ennew's picture
John Ennew
John Ennew

Hi, two things to check,

1. Like all drush commands that are doing site specific things, you must be somewhere inside your website directory when you run it. e.g. cd /home/user1/public_html
2. Is the variable module downloaded and enabled? http://drupal.org/project/variable

Add new comment