Errata (First Edition)

This page lists the errors found in the first edition of the book. Help us improve this book by logging in and submitting any errors you find. In cases where errors exist in the code, they are corrected immediately in the code repository.

Chapter 2. Writing a Module, Page

Location on the page: 
NA
Error: 

Uploading modules results in the following error message:
"Annotate $Name$ Allows users to annotate nodes.
This version is incompatible with the 6.3 version of Drupal core."

Please suggest a fix.

[The first edition of the book covers Drupal 5. The second edition covers Drupal 6. You are using an example from the first edition with Drupal 6. -JV]

Chapter Front Matter, Page

Location on the page: 
All
Error: 

PDF version: almost the entire book is paginated incorrectly so that it's almost impossible to print it properly double-sided. Arrrrg!

Correction: 

Fix blank page(s) in front matter

Description of the Error: 

In the PDF, right pages have numbers on the right side, and are numbered in accordance with normal book convention with odd numbers. However, there's a screw-up in the front matter so that some extra page is added, which means the odd-number-labeled pages are actually even PDF pages. Ie: Printed page 1 is PDF page 28. This is almost impossible to straighten out at print time because *&^%$ Acrobat's dialog offering choice of page range, and whether to print odd or even pages is confused between PDF page number and printed page number. (Not to mention all the confounded Roman numbers in the front matter.)
The problem is likely started by the fact that PDF page 2 should be blank page (inside front cover), but the subsequent several un-numbered and blank pages cause further misery.

Chapter Front Matter, Page 1

Location on the page: 
NA
Error: 

Not clear what version of Drupal is covered.

Correction: 

Include some guidance as to version applicability.

[Book covers Drupal 5. -JV]

Chapter 1. How Drupal Works, Page 2

Location on the page: 
Lower portion of page
Description of the Error: 

The url contained the plural of node(s) instead of just node so if you try to access the "nodes" page on the drupal site you would receive a page not found.

[A redirect was added so both URLs work. -JV]

Chapter 1. How Drupal Works, Page 7

Location on the page: 
Figure 1-5
Error: 

sites > all > modules > views
sites > all > themes > friends electic

Correction: 

sites > all > modules > drupal-contrib > views
sites > all > themes > drupal-contrib > friends electic

Description of the Error: 

The diagram doesn't adhere to the best practices outlined in the rest of the book.

Chapter 2. Writing a Module, Page 13

Location on the page: 
Code section entitled 'Implementation of hook_menu'
Error: 

There is an error in the code for the 'annotate_menu()' function which can be compounded if an attempt is made to enable the Annotation module before many more functions are added to 'annotate.module'. The effect is that the desired menu entry 'Annotation settings' does not display.

Correction: 

The correct code for 'annotate_menu()' looks like this:

function annotate_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'admin/settings/annotate',
'title' => t('Annotation settings'),
'description' => t('Change how annotations behave.'),
'callback' => 'drupal_get_form',
'callback arguments' => array('annotate_admin_settings'),
'access' => user_access('administer site configuration')
);
}
return $items;
}

However, the menu item it is supposed to create will not appear until the Annotate module is in a complete enough state for it to be safely enabled. So disable the module if you have enabled it and install the complete, corrected 'annotate.module' source code available from this site in place of the one copied from the book. Now enable the Annotate module and reload the page in your browser. The 'Annotation settings' menu item should appear.

Description of the Error: 

Menu entry 'Annotation settings' does not display

Chapter 2. Writing a Module, Page 13

Location on the page: 
if ($may_cache)
Error: 

In order to view the menu in admin/settings/annotate, I had to change this line of code:
if ($may_cache)

Correction: 

if (!$may_cache)

I tested this out with the code from this website, and I have the same problem that the menu will not show in admin/settings.

[Using !$may_cache is helpful for development. But the problem you are seeing is outlined in the blog post here. -JV]

Chapter 2. Writing a Module, Page 13

Location on the page: 
mid
Error: 

I've just purchased the Pro Dupal book and installed Drupal Core 6.0. I had trouble getting the sample code on this page — function annotate_menu() — to work in 6.0. The error appeared when I clicked the Enable checkbox for the Annotate module in admin/build/modules.

P.S. Is this typical with changes in major Drupal versions? Should I perhaps work through the book using an earlier version of Drupal?

Correction: 

I had a go at changing the code to something that appears to, but may not in fact, actually work.

I got the function to work in the way described on the lower part of page 15 by changing the code to the following:
/**
* Implementation of hook_menu().
*/
function annotate_menu(){
$items = array();
if (!$may_cache) {
$items['admin/settings/annotate'] = array(
'title' => 'Annotation settings',
'description' => t('Change how annotations behave.'),
'page callback' => 'drupal_get_form',
'page arguments' => array('annotate_admin_settings'),
'access callback' => user_access('administer site configuration')
);

}
return $items;
}

Description of the Error: 

The error message is:

warning: Missing argument 1 for annotate_menu() in /Applications/MAMP/htdocs/drupal/sites/all/modules/annotate/annotate.module on line 14.

Having a look through the Drupal API site led me to what appears to be a revision to the hook_menu() function. The changes seem to be the source of the error.

Chapter 2. Writing a Module, Page 15

Location on the page: 
5th paragraph
Error: 

Administer > Settings > Annotate

Correction: 

Administer > Site Configuration > Annotate

Description of the Error: 

Incorrect path to the annotation settings form.

Chapter 2. Writing a Module, Page 15

Location on the page: 
4th paragraph
Error: 

The values are stored to the variables database table ...

Correction: 

The values are stored to the variable database table ...

Description of the Error: 

Typo: delete the 's' in variables