7.x block.api.php hook_block_configure($delta = '')

Define a configuration form for a block.

Parameters

$delta: Which block is being configured. This is a unique identifier for the block within the module, defined in hook_block_info().

Return value

A configuration form, if one is needed for your block beyond the standard elements that the block module provides (block title, visibility, etc.).

For a detailed usage example, see block_example.module.

See also

hook_block_info()

hook_block_save()

Related topics

10 functions implement hook_block_configure()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

aggregator_block_configure in modules/aggregator/aggregator.module
Implements hook_block_configure().
block_block_configure in modules/block/block.module
Implements hook_block_configure().
blog_block_configure in modules/blog/blog.module
Implements hook_block_configure().
book_block_configure in modules/book/book.module
Implements hook_block_configure().
comment_block_configure in modules/comment/comment.module
Implements hook_block_configure().

... See full list

1 invocation of hook_block_configure()
block_admin_configure in modules/block/block.admin.inc
Form constructor for the block configuration form.

File

modules/block/block.api.php, line 157
Hooks provided by the Block module.

Code

function hook_block_configure($delta = '') {
  // This example comes from node.module.
  $form = array();
  if ($delta == 'recent') {
    $form['node_recent_block_count'] = array(
      '#type' => 'select',
      '#title' => t('Number of recent content items to display'),
      '#default_value' => variable_get('node_recent_block_count', 10),
      '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
    );
  }
  return $form;
}

Comments

tomas.teicher’s picture

the important information is missing - you can use this hook only within the module, that defines the created block.

Alexander Matveev’s picture

Why not to use like:

<?php
variable_get('node_recent_block_count');
?>

--
Regards,
Alexander Matveev

james.williams’s picture

If you're referring to the '10' used as a second argument, that is the default value if the 'node_recent_block_count' variable isn't set to anything.

tatewaky’s picture

that is extremely important you are right +1

hermes_costell’s picture

Be sure to use hook_block_save or any of the custom variables you set will be ignored upon saving the block (and their values will never be saved).

Neograph734’s picture

Should this work with system_settings_form as well? It would make sense to me, but I have not found one example of it.

Neograph734’s picture

Ah snap, that creates another save button which does not work.