Drupal Tools: Variable Files & Devel

These are a few add-ons for Drupal 7 Variable module that just got out of my sandbox. A module to provide a 'File' variable type and a module to help developers keep track of variables and variable types. They are contained in the Variable Extra package, see links at the bottom.

Variable File

This one contains a few extra variable types to be used on other modules: File (Managed and Unmanaged) and Image (Managed and Unmanaged). Hopefully if this one works well, waiting for feedback atm, it will be moved into the main Variable package.

Adding new file/image variables is as easy as adding some similar code in your module's hook_variable_info():

<?php
   
// Unmanaged generic file.
   
$variables['variable_example_upload_file'] = array(
     
'type'              => 'file_upload',
     
'title'             => t('Example file upload', array(), $options),
     
'description'       => t('Upload my config file.', array(), $options),
     
'upload_location'   => 'public://myuploaddir',
    );
 
// Managed image file.
   
$variables['variable_example_managed_image'] = array(
     
'type'              => 'image_managed',
     
'title'             => t('Example image managed', array(), $options),
     
'description'       => t('Upload my config file.', array(), $options),
     
'upload_location'   => 'public://myuploaddir',
    );
?>

And this is how these variables look like on your forms:

Variable Devel

This is a tool for developers that want to implement the Variable API in their own modules. You can find it in the 'Development' modules group after you download the package. It provides a few features:

List of existing variable types that are defined by Variable itself or other modules:
Screenshot: Existing variable types

Clicking on one of the types you can see the full definition:
Screenshot: Variable type detail

Form helper that diplays ready to copy & paste code when visiting any settings form, just in case you want to declare the variables provided by a module.
Screenshot: Variable Form helper