Module Development

Movie Project: Create Custom Blocks for Drupal 7

This page is archived

We're keeping this page up as a courtesy to folks who may need to refer to old instructions. We don't plan to update this page.

Create a custom block with details from the database containing information about user preferences.


Create a custom block that displays a random entry from the user's movie preferences.


You will need the following knowledge and skills. If you need a review, check out the Additional resources section at the bottom of this page.

  1. Define a custom block.
  2. Display and position a custom block.


Define a custom block which retrieves a random entry from the user's movie preferences table created earlier.

Display the username and title of their favorite film.

Position the block in the left-hand sidebar.


  • Blocks can be created programmatically.
  • There are many rules to govern the visibility of blocks.

Further your understanding

Additional resources

Creative Commons License

Drupal Training Resources by Damian Robinson are licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Based on a work at

Hands-On Exercises: Movie Project