Submitted by Techdipu on Thu, 02/26/2009 - 18:28
Many often, you may require a block to show up automatically when a module is installed. This is fairly straightforward, and is achieved through a query that inserts the block settings directly into the blocks table. The query goes within hook_install(), located in your module’s .install file.
Here is an example of the user module enabling the user login block when Drupal is being
installed (see modules/system/system.install):
db_query("INSERT INTO {blocks} (module, delta, theme, status) VALUES
('user', 0, '%s', 1)", variable_get('theme_default', 'garland'));
The above database query inserts the block into the blocks table and sets its status to 1 so that it is enabled.
»
- Techdipu's blog
- 1790 reads













Post new comment