Learning Drupal 6 Module Development
Formats:
save 35%!
save 37%!
Free Shipping!
| Also available on: |
|
- Specifically written for Drupal 6 development
- Program your own Drupal modules
- No experience of Drupal development required
- Know Drupal 5? Learn what's new in Drupal 6
- Integrate AJAX functionality with the jQuery library
- Packt donates a percentage of every book sold to the Drupal foundation
Book Details
Language : EnglishPaperback : 328 pages [ 235mm x 191mm ]
Release Date : May 2008
ISBN : 1847194443
ISBN 13 : 9781847194442
Author(s) : Matt Butcher
Topics and Technologies : All Books, Drupal
Table of Contents
Preface
Chapter 1: Introduction to Drupal Modules
Chapter 2: Creating Our First Module
Chapter 3: The Theme System
Chapter 4: Theming Modules
Chapter 5: Using JavaScript and AJAX/JSON in Modules
Chapter 6: An Administration Module
Chapter 7: Building a Content Type
Chapter 8: Filters, Actions, and Hooks
Chapter 9: An Installation Profile
Index
Matt Butcher
Learning Drupal 6 Module Development is the most promising and information-rich resource for Drupal developers interested in creating their own modules and themes. Michael J. Ross, Web Developer
Code Downloads
Download the code and support files for this book.
Submit Errata
Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.
Errata
- 40 submitted: last submission 08 Aug 2012Errata type: Technical | Page number: 0
Note on code indentation:
The author says ""I have attempted to make the code in the book adhere to the Drupal coding standards (http://drupal.org/coding-standards). I suggest that, in Chapter 1, developers use the Coder module to help keep code close to that standard. However, there is no prolonged discussion in the book of what the standards are. For that information, readers should visit http://drupal.org/coding-standards."
Errata type: code | Page number: 0
In the download code, modul philquotes code_example.zip: function _philquotes_get_quote() /query statement: ...type='quotes'...(plural) In the book the statement is: ...type='quote'... (singular). Correction: 'quote' is correct.
Errata type: Technical | Page number: 18
The book says JSON stands for JavaScript Over The Network. But it actually stands for JavaScript Object Notation.
Errata type: Typo | Page number: 19
Under "Developers' Tools" there is a line that reads "These tools are themselves provided by two modules, which can both can be obtained from the Drupal site." This sentence should not contain the second "can".
Errata type: Technical | Page number: 20
In the list of development environments, vi and Firebug are incorrectly capitalised as "VI" and "FireBug".
Errata type: Typo | Page number: 38
The first line of the first paragraph should be "This tool" instead of "This tools"
Errata type: Typo | Page number: 40
The first line of the comments for the _gooreads_fetch_bookshelf($url, > $num_items = 3) functions has bookshelf spelt wrong as bookshelp.
Errata type: Technical | Page number: 40
In the second paragraph, the given RSS URL is not working anymore. The new RSS URL is http://www.goodreads.com/review/list_rss/398385
Errata type: code | Page number: 45
The part of the code under the topic 'Processing the HTTP Results' should read:
if($doc === false) {
$msg = "Error parsing bookshelf XML for %url.";
$vars = array('%url => $url); watchdog('goodreads', $msg, $vars, WATCHDOG_WARNING);
return t("Getting the bookshelf resulted in an error"); }
Errata type: Code | Page number: 46
The $num_items variable is not used to limit the number of items displayed (as it should be). The code sample on page 46 (repeated on page 49) should have included this around line 6 of the function:
if ($count_items > $num_items) {
$items = array_slice($items, 0, $num_items, TRUE); }
Since the variable $len is not used, it can be removed.
Alternately, the foreach loop could be replaced with a for loop, which was the
original design. In this case, $len is used:
// foreach ($items as $item) { // Not used anymore for ($i = 0; $i < $len; ++$i) {
$item = $items[$i];
// ... rest of the code goes here
}
Errata type: code | Page number: 57
In the code sample at the top of the page, default values for the $author and $title variables are left empty. They should have been set to 'Unknown' and 'Untitled', respectively. The correct code appears on page 49 and again on page 51 (where it is explained).
Errata type: Code | Page number: 47
There is a wrong line of code. It says "if (empty($link)) !== 0) $link = $default_link;" it should be "if (empty($link)) $link = $default_link;"
Errata type: Code | Page number: 49
The $num_items variable is not used to limit the number of items displayed (as it
should be). The code sample on page 46 (repeated on page 49) should have included
this around line 6 of the function:
if ($count_items > $num_items) {
$items = array_slice($items, 0, $num_items, TRUE); }
Since the variable $len is not used, it can be removed.
Alternately, the foreach loop could be replaced with a for loop, which was the
original design. In this case, $len is used:
// foreach ($items as $item) { // Not used anymore for ($i = 0; $i < $len; ++$i) {
$item = $items[$i];
// ... rest of the code goes here
}
Errata type: Typo | Page number: 52
In the first line of the fourth paragraph, it should be "That string is then added to $out." instead of "That string is then added to $output."
Errata type: Typo | Page number: 61
In the middle of the page 'labotomy' is misspelled in code block, it should be spelled 'lobotomy'
Errata type: Typo | Page number: 63
The first sentence on page 63 which reads, "In this book, we will use only of the PHPTemplate engine for the following reasons:", is grammatically wrong. The sentence should not contain "of".
Errata type: Typo | Page number: 68
The fourth paragraph has the sentence, "In our case, we are extending a theme that we did not create. Clearly, we would do best to put our MODULE in the drupal/sites/all areas." The word module should be theme.
Errata type: Code | Page number: 71
Right after the sixth line of code at the top of the page "background-color: white;" should be a line that is missing "float: right;".
Errata type: Code | Page number: 72
The current code says:
stylesheets[all][] = style.css
stylesheets[all][] = new.css
Should be like this:
stylesheets[all][] = descartes-style.css
stylesheets[all][] = new.css
Otherwise the subtheme will not inherit style.css from bluemarine.
Errata type: Technical | Page number: 79
Last paragraph refers to "one for the right region" for two column layout, should refer to "left region"
Errata type: Language | Page number: 79
In the NOTE "CSS and the left and right regions" there is a line which reads "We styled these while developing our CSS-only theme earlier", it should read "We styled these while developing our CSS theme earlier"
Errata type: Technical | Page number: 79
The author has written "sell" instead of "cell" in the paragraph after code:- Each "sell" corresponds to a region: left, content, and right.
Errata type: Technical | Page number: 81
The first line should read: "If we look at the home page", not "if we look at the site".
Errata type: Technical | Page number: 85 | Errata date: 18 Dec 08
The second sentence in the second-to-last paragraph begins:
Invoking theme('images', $a, $b) causes...
It should read:
Invoking theme('image', $a, $b) causes...
Errata type: Typo | Page number: 87
The first word of the first sentence after the css script should "The" and not "These"
Errata type: Technical | Page number: 88
In the section "template.php Gotchas", it is written that you can override a function only once. The function 'phptemplate_breadcrumb()' has been used as an example. However, it is not true; use the function 'descartes_breadcrumb()' instead.
Errata type: Code | Page number: 101
The code on page 101 was written to exhibit the basics of Drupal DB code. However, it could be rewritten to take advantage of more specialized aspects of the database API. Instead of using a LIMIT clause in the SQL (which is not portable across various databases), we should use the db_query_range() function. Since the returned entry will have no more than one row with one column, we could use db_result() instead of db_fetch_object(). In the example, that will return the NID (Node ID).
Errata type: Code | Page number: 106
The code sample at the top of the page should be,
return array(
'theme_a' => array(/* settings */),
'theme_b' => array(/* settings */),
'theme_c' => array(/* settings */),
);
All three lines should end in commas instead of semicolons.
Errata type: Technical | Page number: 113
In the fifth paragraph, "philqyotes" should be "philquotes".
Errata type: Code | Page number: 114
stylesheet[all][] = philquotes.css
should be stylesheets[all][]
Errata type: Technical | Page number: 134
In the paragraph starting with "Note that the registered..." in one of the parentheses you have "http://localhost/drupal/q=philquotes.json" this should be "http://localhost/drupal/?q=philquotes.json" notice the question mark.
Errata type: Code | Page number: 167
In the code example, the method 'emailusers_mail' states:
$my_account = user_current_load(null);
it should be:
$my_account = user_load(null);
Errata type: Code | Page number: 167
In the code snippet, the method named 'user_current_load()' should be 'user_current_self()'
Errata type: Code | Page number: 173
In the hook_mail_alter() implementation, the $message['body'] .= t($append, $args);
only works if you don't have an array for the message body already only a single string. The solution is either:
1. Append the disclaimer to the end of the message array by using
$message['body'][] = t($append, $args);
In this case the hook_mail implementation also needs to create bodies as such by using:
$message['body'][] = $params['body'];
2. Use the $message[id] variable inside the hook_mail_alter to make sure we're only appending the disclaimer to messages generated by our own module and not append it to every single outgoing mail.
Errata type: Code | Page number: 196
There is a typo in the code comment. It reads "Existing files: title ...". It should read "Existing fields: title..."
Errata type: Code | Page number: 197
There is a typo in the code. "#maxlengh" should be "#maxlength"
Errata type: Technical | Page number: 209
The update function doesn't work that way. There must be a Top of Form _submit function which gets the form and form_state parameter. Form has the new values, form_state the old values, but later in the drupal code, form_state is used to rebuild the node information before update is called. In the submit function one has to store the changed fields into the form_state array.
Errata type: Code | Page number: 239
In the fifth paragraph and comments of the example function reference, 'hook_filter_info()' should be 'hook_filter_tips()'.
Errata type: Technical | Page number: 269
In the code demonstrating the original document it says {{report name}}, it should be {{brief name}}.
Errata type: Technical | Page number: 269
In paragraph 6 it talks about the footer added by philquotes_mail_alter() which should be emailusers_mail_alter()
Sample chapters
You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.
- A developer's overview of important Drupal concepts and APIs, like nodes, menus, and forms
- Using Drupal tools for module development
- Creating a new module from scratch
- Harnessing the power of the Drupal hook system
- Using key Drupal functions
- Creating custom content types, from basic to advanced
- Performing database operations
- Writing module installers and uninstallers
- Making Drupal content available to JavaScript with a JSON service
- Interacting with the theme system to build crisp layouts
- Creating richer user interfaces with Drupal's JavaScript libraries
- Working with blocks, nodes, actions, and menus
- Using a web service to retrieve and display XML data
- Creating an administration interface
- Customizing user profiles
- Writing actions and triggering them with events
- Working with the Forms API
- Defining custom hooks and making modules work together
- Exploring the database and schema API
- Creating an installation profile to bundle your modules into a custom Drupal distribution
With great power comes... tremendous flexibility. Drupal is an award-winning open-source Content Management System, and the feature-packed sixth release is right around the corner. It's a modular system, with an elegant hook-based architecture, and great code. These are a few of the perks that make Drupal a choice platform for developers who want the power of an established CMS, but the freedom to make it work for them. From social networking to AJAX to e-commerce, the hundreds of existing modules attest to Drupal's flexibility. When you create a new module for Drupal, it fits seamlessly into the look and feel of your overall site. If you can think it in PHP, you can code it as a Drupal module.
Dive into Drupal module development as we create the Philosopher Biographies website, developing new modules and themes to meet practical goals. Create custom content types. Add AJAX functionality with the jQuery library. Use external XML APIs to add content to your site. Email newsletters to site members. Use themes. Empower administrators with extra features. And bundle it all up in a custom installation profile. You won't find a "hello world" here!
If you're eager to start creating modules for Drupal 6, this is your book. Walk through the development of complete Drupal modules with this primer for PHP programmers. Specifically written for Drupal 6, this book will get you coding modules as quickly as possible, and help you add the features that will give your work that professional gloss!
Just getting started with Drupal development? This book will give you a clear, concise and, of course, practical guidance to take you from the basics of creating your first module to developing the skills to make you a Drupal developer to be reckoned with.
Are you a Drupal developer looking to update to version 6? This book covers the new and updated APIs to guide your transition to Drupal 6. The new menu system, the Forms and Schema APIs, and many core revisions are covered in this book.
Walk through the development of complete Drupal 6 modules with this primer for PHP programmers, written specifically for Drupal 6 to get you started coding your first module.
Are you a Drupal developer looking to update to version 6? This book covers the new and updated APIs to guide your transition to Drupal 6. The new menu system, the Forms and Schema APIs, and many core revisions are covered in this book.
This book is written for PHP developers who want to add custom features to Drupal. You will need to know the basics of PHP and MySQL programming, but no experience of programming Drupal is required, although you will be expected to be familiar with the basic operation of Drupal.

