Creating a block


show more Creating a block provides you with in-depth training on Developer. Taught by Jon Peck as part of the Drupal 7 Custom Module Development show less
please wait ...

Creating a block

A Drupal block is an area which displays content whose position is controlled by the theme and administrative block settings. I'm going to programmatically create a block that shows a map of wind farms that are within 100 miles of the center specified. To help us some of the computation I'm going to leverage a library that is within the location module. There is no need to actually enable the location module to do this, but it does need to be there. Open windfarms.module and scroll to the end. Two functions are needed to generate a block and I will use a third to keep the code tidy.

The first function that's needed is an implementation of hook_block_info. By implementing this hook, I can declare to Drupal that a block with a particular machine name and human readable administrative name exists. Start with a docblock, Implements hook_block_info. Hook_block_info requires no parameters and returns a nested array, function windfarms_block_info, blocks = array.

Hook_bloc...

Creating a block
Video duration: 17m 38s 2h 56m Advanced

Viewers:

Creating a block provides you with in-depth training on Developer. Taught by Jon Peck as part of the Drupal 7 Custom Module Development

Subjects:
Developer Web
Software:
Drupal
Author:
please wait ...