when
hook_block_info()
hook_block_configure()
hook_block_save()
hook_block_view()
are get called? is it possible to call these hooks manually in a module?
From the comments, I think you're confusing things a bit. There are two types of block:
Custom
the ones you create through the UI. The content for these is stored in the block_custom
table.
Programatically defined
the ones that Drupal auto-discovers for modules that implement hook_block_info()
. The content for these is defined in hook_block_view()
, and is built on-the-fly, so to speak. The content can be cached, but when that cache is invalidated the implementation of hook_block_view()
will be responsible for re-building it. Drupal doesn't store this content anywhere on your behalf.
You can use either type for your needs. If you want to use custom blocks there's a good approach here.
If you want to use the hooks, the approach should be like this (this assumes you have a data table called my_table
that you've populated with the necessary content for the block):
function MYMODULE_block_info() {
// Get identifiers for all your custom blocks.
$deltas = db_query('SELECT delta FROM {my_table}')->fetchCol();
$blocks = array();
foreach ($deltas as $delta) {
$blocks[$delta] = array( /* Block definition */ );
}
return $blocks;
}
function MYMODULE_block_view($delta = '') {
$block = array();
if (!empty($delta)) {
// Get your custom data for this delta
$data = db_query('SELECT * FROM {my_table} WHERE delta = :delta', array(':delta' => $delta))->fetchObject();
// And populate the block with it.
$block['subject'] = $data->title;
$block['content'] = $data->content;
}
return $block;
}
Obviously that's a trivial example and you'll want to add error checking and the like, but it should get you started. Note that you won't be able to have a temporary table as such with this method, your data will need to persist so it can be re-queried when the time comes.
x invocations of hook_hook()
and expand it to show links to the relevant functions