
I received in the mail my pre-ordered copy of Pro Drupal Development Second Edition yesterday.
The book is a brick. 667 pages with the index.
I am a little disappointed already... To be fair, I had high expectations. The treatment JavaScript and Ajax would receive was the first thing I'd look into.
AHAH is covered but the example provided is lame. It does not cover modifications to a form... Well it does, but you only inject some text in a field of type markup, so you do not need to fiddle with the cached form, or even read anything from it in the callback function. (The callback function is the PHP function that 'writes' the JSON that's returned to the browser...).
The chapter on jQuery provides one additional example module, besides PlusOne. That other module only attaches an additional JavaScript file to the page, using HOOK_init() and a registered theme function. No Ajax.
PlusOne still doesn't does degrade in this Drupal 6 version (see comments below). The book Learning Drupal 6 Module Development provides an example that does degrade. Meaning: without JavaScript, things won't look broken, as they do with the PlusOne module.
The chapter on jQuery explains how to add a function to Drupal.behaviors, but it does not explain how to pass a variable from Drupal PHP to the client-side Drupal.settings namespace. Learning Drupal 6 Module Development does explain this. It becomes important to use drupal_add_js to pass PHP variables over to our JavaScript to always avoid hard-coding certain values in our scripts.
We learned that in Drupal 6 our JavaScript is themable. Example, please? The book provides none.
(Any module's JavaScript file that produces HTML content must now provide default theme functions in the Drupal.theme.prototype namespace.)
The book does not even show one case where Drupal.t() is used. That function should have been mentioned at least.
Coverage of JavaScript best coding practices (such as... use camelCase for 'variable' and function names, etc.) should have found its place somewhere in that second edition, because the Drupal community and this very book are pushing hard for coding standards.
The book Learning Drupal 6 Module Development has its own shortcomings in its treatment of JavaScript due to the timing of its publication probably. By the way, the author of Learning Drupal 6 Module Development, Matt Butcher, has encouraged Drupal.org to update its handbook JavaScript coding standards page, to extend it based on a more thorough definition. Kuddos to him. JavaScript and Ajax are that important. Contributed modules developer (I am part of them) need to follow some conventions.
Comments
Do you have the previous edition?
If so, would it be worth buying the new one?
I have the previous edition and it has proved exceedingly useful.
Also, I really rather like what you've done with the Garland theme. All the little tweaks really round it off especially the feed icon/mug.
Yes I do
I have the previous edition, and it was extremely useful to me as well. I read it from cover to cover.
I have only skimmed this new revision. From what I see here, and although this may be premature of me to say so, I still believe that it's worth getting for someone who has the older edition.
For someone who never read the first edition, then, by all means, do get this book, but you may be interested in also getting your hands on the Other book, by Matt Butcher. If you get both books, read Matt Butcher's book first. The style is much more engaging, and Matt Butcher is thorough, and is a fantastic writer. The style of the other book allows you to learn module development in one long week-end, and none of the examples in the book are contrived.
Thanks
Hi, Caroline. Thanks for your comments. You're the first person I've heard of to receive the 2nd edition.
I wish I had had you as an additional reviewer for the jQuery chapter!
I do think that the Plusone module degrades well. For me, the only difference is that with JavaScript off there is a full page submit instead of AJAX.
Best regards,
John
You're right
Oh yeah! My mistake.
The code is different from its earlier Drupal 5 version. I had missed a snippet of code added to it.
There is only one callback function, still, except that it has a different behavior when JavaScript is disabled.
On page 399:
Congratulation, and sorry for biting your head off over that one, this is a major improvement over the First Edition.
To get the redirect $path, though, a simple call to url() will provide the alias if there's one. url() or l() — to get the anchor element, are Drupal developers' best friends. See this page: http://api.drupal.org/api/function/url/6.
Yes, I got the book rather quickly. Even Chapters Indigo (that sent the book to me, by normal slow mail), marks it as "pre-order" item, still.
I am lucky :-) I was impatiently waiting for it, that's why.
Does the second edition have
Does the second edition have any info on working with Simpletest? I'd love to see more info on that in book form.
Nothing on SimpleTest, no
There is no entry in the index under SimpleTest.
Under Testing and developing code, there is something, but the pages you are referred to show you how to use the Devel module.
Providing 2 callback functions...
The module PlusOne could, alternatively, provide two menu paths mapped to their individual callback function. There would be one callback function for the JSON 'service' and an other for the non-ajaxified JavaScript-disabled-in-the-browser route.
The JavaScript function executed when the DOM is ready could 'bind' a click event-handler to the vote link, an event-handler that would call the JSON service, reading the JSON URL from Drupal.settings.plusone.jsonUrl, for example — provided we set this property on the Drupal JavaScript object using the drupal_add_js function like so:
There is one limitation to this: there ought to be only one voting widget on the page... as it stands now, the module only shows the widget on the page view so we're fine.
We would then avoid reading from the $_POST array to guess whether JavaScript is enabled or not.
Something else I find a little strange
There is no wildcard used for the node id in the path.
HOOK_menu is defined like so:
While the callback function does take a node id as parameter...
I would have used this HOOK_menu implementation instead:
Both ways are perfectly valid
On page 65 of Chapter 4, The Menu System, we read this:
I guess the author meant "not defining page arguments" in the HOOK_menu implementation... can be useful.
What percent of the book is new?
The book has a new co-author. I'm wondering if there are perhaps a couple of new chapters that were written by Dries. Hope his name isn't on it just to sex it up.
Dries only wrote the preface
Actually the book has one less author. Matt Westgate is not authoring the Second Edition — although... the Second Edition still reads like the First Edition with updates whenever applicable, so you could say that Westgate is still behind the Second Edition.
Dries still wrote a preface for this book, as he had for the First Edition.
There is obviously new content, as Drupal 6 has new features.
Right off the bat, I see two new chapters:
Chapter 3: Hooks, Actions and Triggers.
Chapter 23: Installation profiles.
Post new comment