Errata (Second Edition)

This page lists the errors found in the book.

Chapter 7. Working with Nodes, Page 141

Chapter: 
7. Working with Nodes
Error: 

I build the projects as described. I downloaded the Joke content type code directly from this site, but I get the following error message in the Drupal admin console:

This version is incompatible with the 6.14 version of Drupal core.

Correction: 

[You are using the downloadable code from the first edition of the book, which works only with Drupal 5. Download the code for the second edition of the book, which works with Drupal 6.]

Chapter 7. Working with Nodes, Page 146

Location on the page: 
Code, 5th line from the bottom
Chapter: 
7. Working with Nodes
Error: 

function joke_form($node) {

Correction: 

Should be:
function joke_form(&$node) {

Description of the Error: 

In print, parameter $node should be passed by reference since it can be altered / augmented in within hook_form.

Chapter 7. Working with Nodes, Page 150

Location on the page: 
final code example for hook_delete()
Chapter: 
7. Working with Nodes
Error: 

function joke_delete(&$node) {

Correction: 

function joke_delete($node) {

Description of the Error: 

Unnecessary passing of parameter $node by reference

Chapter 7. Working with Nodes, Page 154

Location on the page: 
Just after the code for node-joke.tpl.php
Chapter: 
7. Working with Nodes
Error: 

Drupal will automatically include the JavaScript file that enables collapsibility.

Correction: 

The sentence should be deleted.

Description of the Error: 

This is true for fieldsets in forms that use the #collapsible property, but not for template files.

Chapter 7. Working with Nodes, Page 154

Location on the page: 
After template code example
Chapter: 
7. Working with Nodes
Error: 

There seems to be a further required step missing here as there is nothing to load the required collapse.js script.

Correction: 

Inserting the line:
drupal_add_js('misc/collapse.js');
into the joke_load function makes the collapsible field work.

Description of the Error: 

A missing paragraph?

Chapter 7. Working with Nodes, Page 154

Location on the page: 
code example
Chapter: 
7. Working with Nodes
Error: 

the fields are not collapsed automatically. With drupal 6.8, I can find no file named "collapsible.js" in the distribution. At http://www.drupalbook.com/node/137, there is mention that the collapsing Javascript is included automatically only in forms, but even adding form tags to the page does not seem to make the collapsability thing work.

Did I miss something about turning on JS includes?

Description of the Error: 

[The file that contains the JS is at misc/collapse.js. Drupal's fieldsets are collapsible by default. -JV]

Chapter 7. Working with Nodes, Page 157

Location on the page: 
midway on the flowchart
Chapter: 
7. Working with Nodes
Error: 

Desicion box, "Providing module implements view hook?" The "No" branch leads to "Call hook_view() on providing module". If this is intended, the structure is counter-intuitive and should be explained in detail. If a module does not implement hook_view(), how is it being called?

Correction: 

It seems the Yes and No branch should be switched.

[Correct -- the Yes and No branch are reversed. -JV]

Chapter 8. The Theme System, Page 170

Location on the page: 
Near top
Chapter: 
8. The Theme System
Error: 

<div id="left">

Correction: 

<div id="sidebar-left">

Description of the Error: 

This div has an ID of "sidebar-left" on all of the code that follows.

Chapter 8. The Theme System, Page 174

Location on the page: 
Within code sample
Chapter: 
8. The Theme System
Error: 

3 new additions to the code have not been made bold.

Correction: 

The following portions should be bold for consistency:
<?php print $breadcrumb ?>
<?php print $title ?>
<?php print $closure ?>

Description of the Error: 

Minor formatting inconsistency.

Chapter 8. The Theme System, Page 181

Location on the page: 
First Example on page
Chapter: 
8. The Theme System
Error: 

The snippet used to override the breadcrumb seems to be incorrect. When following the guidelines, the order Drupal pulls this information is either incorrect in the book, or is coded incorrectly.

Correction: 

The theme registry needs to be cleared in order for new template overrides to be active.

To clear the theme registry, do one of the following things:

1. On the "Administer > Site configuration > Performance" page, click on the "Clear cached data" button.
2. With devel block enabled (comes with devel module), click the "Empty cache" link.
3. The API function drupal_rebuild_theme_registry.

Description of the Error: 

More information can be found here: http://drupal.org/node/173880#theme-registry