18.10.2016 Views

Drupal 7 Module Development

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Table of Contents<br />

Tools for developing <strong>Drupal</strong> code 20<br />

Version control with Git and CVS 21<br />

The book's code and Git 21<br />

The API site and coding standards 22<br />

Developer-oriented modules 22<br />

The developer module 22<br />

Drush (the <strong>Drupal</strong> shell) 23<br />

Coder 23<br />

Summary 23<br />

Chapter 2: Creating Your First <strong>Module</strong> 25<br />

Our goal: a module with a block 25<br />

Creating a new module 26<br />

<strong>Module</strong> names 27<br />

Where does our module go? 27<br />

Creating the module directory 29<br />

Writing the .info file 29<br />

Creating a module file 33<br />

Source code standards 35<br />

Doxygen-style doc blocks 36<br />

The help hook 38<br />

The t() function and translations 39<br />

Working with the Block API 42<br />

The block info hook 43<br />

The block view hook 45<br />

The first module in action 48<br />

Writing automated tests 49<br />

Creating a test 50<br />

Starting out 50<br />

Writing a test case 51<br />

The basic pattern 51<br />

The getInfo() method 52<br />

Setting up the test case 54<br />

Writing a test method 55<br />

Summary 60<br />

Chapter 3: <strong>Drupal</strong>'s Theme Layer 61<br />

Business logic versus presentation logic 62<br />

Data granularity 64<br />

Theme engines 66<br />

Two ways to theme 66<br />

Theme functions 66<br />

Preprocess functions 68<br />

Theme overrides 69<br />

[ ii ]

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

Saved successfully!

Ooh no, something went wrong!