18.10.2016 Views

Drupal 7 Module Development

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Creating Your First <strong>Module</strong><br />

The report above shows us that all four of our assertions were run (two for each test),<br />

and that all passed.<br />

Should a test not pass, it will be displayed in red, with the status flag set to a red X<br />

instead of a green checkmark. A warning message may be displayed, too (depending<br />

on the error or failure).<br />

Summary<br />

We have now completed an end-to-end walk through the creation of a module. We<br />

began by creating the module directory, followed by the .info file. Next, we added a<br />

.module file and implemented three hooks, taking advantage of several core <strong>Drupal</strong><br />

functions in the process. Finally, we wrote our first test for this module, learning<br />

about <strong>Drupal</strong>'s OO testing framework as we went.<br />

Along the way, we learned about basic coding guidelines, translation support, the<br />

mechanics of hooks, and using the block API.<br />

In subsequent chapters, we will build on this knowledge to create more powerful<br />

modules, making use of the database layer, the menu system, nodes, and other tools.<br />

In the next few chapters, we will look at the theme system, a powerful and extensible<br />

mechanism for structuring and formatting output.<br />

[ 60 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!