Defining a Block

Blocks are defined within modules by using hook_block_info(), and a module can implement multiple
blocks within this single hook. Once a block is defined, it will be shown on the block administration
page. Additionally, a site administrator can manually create custom blocks through the web interface. In
this section, we’ll mostly focus on programmatically creating blocks.

The following properties are defined within the columns of the block table:
bid: This is the unique ID of each block.

module: This column contains the name of the module that defined the block.
The user login block was created by the user module, and so on. Custom blocks
created by the administrator at Structure -> Blocks -> Add Blocks are
considered to have been created by the block module.

delta: Because modules can define multiple blocks within hook_block_info(),
the delta column stores a key for each block that’s unique only for each
implementation of hook_block_info(), and not for all blocks across the board. A
delta should be a string.

theme: Blocks can be defined for multiple themes. Drupal therefore needs to
store the name of the theme for which the block is enabled. Every theme for
which the block is enabled will have its own row in the database. Configuration
options are not shared across themes.

status: This tracks whether the block is enabled. A value of 1 means that it’s
enabled, while 0 means it’s disabled. When a block doesn’t have a region
associated with it, Drupal sets the status flag to 0.

weight: The weight of the block determines its position relative to other blocks
within a region.

region: This is the name of the region in which the block will appear, for
example, footer.