Skip to content

Instantly share code, notes, and snippets.

@ccamara
Last active December 22, 2015 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ccamara/6462267 to your computer and use it in GitHub Desktop.
Save ccamara/6462267 to your computer and use it in GitHub Desktop.
How to rename a #variable in #drupal
<?php
/**
* Renames a function
*/
function yourmodule_default_theme_settings() {
$new_variable_name = variable_get('old_variable_name', NULL); //Loads the variable to be renamed from drupal's variables table and assigns it to a new one.
variable_set('new_variable_name', $new_variable_name); //Stores $new_variable_name into drupal's variables table.
variable_del('old_variable_name'); //Deletes the old variable from drupal's variables table
}
@ccamara
Copy link
Author

ccamara commented Sep 6, 2013

It can be also usefull to call this function from yourmodule's hook_install

function yourmodule_install() {
  yourmodule_default_theme_settings();
}

and hook_update:

/**
 * Your message goes here.
 */
function yourmodule_update_7001() {
  yourmodule_default_theme_settings();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment