By bernardl on
Let's say I have just installed a module, is there a way to programmically enable it (administer -> modules -> enable) as well as add it to the blocks (blocks -> enable) without going through the Drupal interface?
Thanks!
Let's say I have just installed a module, is there a way to programmically enable it (administer -> modules -> enable) as well as add it to the blocks (blocks -> enable) without going through the Drupal interface?
Thanks!
Comments
Not at this time. I'm not
Not at this time. I'm not sure such a feature would be a good idea, either. Enabling modules without feedback to the admin could cause a whole host of problems.
-- Merlin
[Point the finger: Assign Blame!]
[Read my writing: ehalseymiles.com]
-- Merlin
[Read my writing: ehalseymiles.com]
[Read my Coding blog: Angry Donuts]
development
Merlin wrote:
I'm not sure such a feature would be a good idea, either.If you've got a developing and a productiv system on different servers you don't want to activate all new modules manually after pushing them to the productiv system.
But this is a special case and if one needs it, he can use a sql script with the calls I posted in my other answer.
best regards,
Stefan
system.module
Hi.
If you'll have a look at the system.module (function "system_module_listing") you see how drupal activates a module.
Lets assume you will activate a module called "myModule" (located at "modules/myModule/myModule.module"):
1.: execute your sql-script (if the module needs one) to update the database and insert your initial data
2.: // Update the contents of the system table:
db_query("DELETE FROM {system} WHERE name = '%s' AND type = '%s'", 'myModule', 'module');
db_query("INSERT INTO {system} (name, description, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d, %d)", 'myModule', 'description', 'module', 'modules/myModule/myModule.module', 1, 0, 0);
I did not test it but this should work.
hth,
Stefan