Chapter 17. Module Development Start to Finish

WHAT YOU WILL LEARN IN THIS CHAPTER:

  • Choosing your hook

  • Offering assistance to site users

  • Adding custom administrative settings

  • Custom permissions

  • Storing data in the database

  • Creating a custom block

  • Testing your module

The previous chapters introduced how modules are built and introduced hooks, the core of a module. Contributed modules contain much more than a hook implementation though. Administrative settings, database tables, custom help text, and permissions are just a few of the pieces of a complete module. In this chapter you'll bring together your knowledge of hooks and Drupal to build a full module from start to finish.

You'll walk step by step through the entire process of building a module. Start off slowly with a few lines of code, implemen a hook and then gradually build on top of it until you have a full module robust enough to be contributed on drupal.org, given to a client, or used as a sustainable solution on your own website.

THE MODULE

The module you will be building in this chapter searches for keywords within comments and if present restricts the comment from being posted. You will also create a custom database table to store the number of times the user attempts to post a comment containing restricted keywords.

When you are finished, you will have utilized and practiced the following hooks and APIs:

  • hook_form_alter and the Forms API

  • hook_menu

  • hook_help

  • hook_permission

  • hook_install, hook_uninstall, hook_schema and the Schema API ...

Get Beginning Drupal® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.