/ Published in: PHP
Drupal allows hook_update_N to run any sort of code. Most of the time, however, people only use this to alter the database scheme.
But you can use it for much more. Like setting variables, creating nodes, importing views and so on.
This code shows how to set a series of variables in Drupal.
When you deploy this code, running update.php will set all the variables as in the listing.
I typically catch this in a module called 'projectname_meta'. So this function would go in projectname_meta.install, and will be called from projectname_meta_install and projectname_meta_update_5002, for example.
But you can use it for much more. Like setting variables, creating nodes, importing views and so on.
This code shows how to set a series of variables in Drupal.
When you deploy this code, running update.php will set all the variables as in the listing.
I typically catch this in a module called 'projectname_meta'. So this function would go in projectname_meta.install, and will be called from projectname_meta_install and projectname_meta_update_5002, for example.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * Sets a variable range of variables to LUX-values. * * @return * An array of name=>value pairs containing the var and its value. */ function _projectname_meta_set_variables() { 'site_name' => 'My New Site!', 'site_offline' => FALSE, ); foreach($variables as $key => $value) { variable_set($key, $value); $statii[] = "$key => $value"; } }
URL: http://wizzlern.nl