This project is not covered by Drupal’s security advisory policy.
D7 - currently in the process of building a Drupal 7 module.
This module provides an interface for managing arbitrary key-value pairs stored in Drupal's 'variables' table.
Constants are simple key-value pairs. They are stored in Drupal's core 'variables' table with a 'CONSTANT:' namespace to differentiate them from other variables. The module provides simple get-save-delete functions to mask the namespace.
Constants aren't really constant at all, but are ideal for replacing values that might otherwise be hard-coded as PHP constants.
For example, node id's are often hard-coded for theming purposes, but can change from site to site, so this allows for easy management of those values. This UI can also be used for any other scenario where a whole admin UI isn't needed to manage a few variables.
The use case I built this for: I was building a complex form on a development site using the Webform module. Webform uses the node id (nid) in the
webform_client_form_NID), so I needed to hard-code the nid in a hook_form_alter for custom form handling. This was fine on the development site, but when I wanted to deploy it to a production (or other) site (using node_export), all my custom nid-based theming and form handling broke. (And if I changed the hard-coded value, it would break on the development site.) So I made a simple UI to handle the nid as a variable, changed the nid as needed for each site, and the form worked everywhere.
I'd be very interested in hearing what other use cases people have, or if I've duplicated work already done elsewhere.
To install, enable the module, grant the "administer constants" permission to your role, and navigate to /admin/settings/constants.
- Maintenance status: Actively maintained
- Development status: Under active development
- Reported installs: 4 sites currently report using this module. View usage statistics.
- Downloads: 1,604
- Last modified: December 1, 2014
- This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.