a work on process

Viewing posts tagged: drupal

Book Review: Drupal 5 Themes

5 February 2008 (10:40 am)

By James Stewart
Filed under: Book Reviews
Tagged: , , , , ,

Drupal 5 Themes book sleeveAimed at those with a knowledge of HTML and CSS but with no prior experience of programming, Drupal 5 Themes sets out to show you how you can quickly and easily get a drupal site up and running with a highly customised look and feel.

Drupal is highly themeable, with most aspects of the user interface being accessible purely in the theme layer without needing to dip into module development or the CMS’ core. The book takes the user through the various theme hooks and introduces the simple PHP code needed to override them, add new ‘regions’ (in which blocks can be displayed), customise existing themes and create your own (almost) from scratch. The primary focus is on the default theme engine, PHPTemplate, but others are referenced and a little time is spent on the options for building your own theme using raw PHP (without the extra layer of a theme engine).

For the most part the content is straightforward, and the reader should quickly get a feel for the naming conventions that drive the PHPTemplate approach. While not much programming knowledge is needed, it would be helpful for the reader to have a basic grasp of PHP and introductory programming constructs such as loops and conditionals. I was also surprised to find recommendations to name functions phptemplate_* within theme-specific template.php files, where they could instead be prefixed with the theme’s name rather than ‘phptemplate’. PHP’s not fond of functions that share names within the same context, and it is best to give those functions the most specific name available to you in order to avoid errors.

Given the fact that only HTML and CSS are listed as pre-requisites I was a little surprised that the PHP code wasn’t introduced in a more focussed section. Given its simplicity it’s to be hoped that anyone intending to spend much time building drupal sites would be able to figure it out, but while time is spent picking apart example code little time is spent actually giving a conceptual introduction or, for that matter, on explaining how to install drupal in the first place. Surprisingly, space was given to explaining how cascades work in CSS, which you would think is a fundamental part of a knowledge of CSS and unnecessary in this context.

This is the second book in a row that Packt has sent me for review where it has seemed that reference material is scattered too freely amongst the tutorial-style chapters. Significant chunks of space are given over to listing off functions, the locations of stylesheets, and so on, which is useful information but breaks up the flow of the book unhelpfully. It’s surprising that that content wasn’t moved to an appendix or, as with their jQuery books, a separate volume. Sitting in the middle of the book it feels like unnecessary filler (just one or two examples would do, along with a reference to an appendix, other volume, or online source) and the space could helpfully be given to more detailed tutorial material. That coupled with poor print quality and light paper stock (both also an issue with that previous book) gives the book a lightweight feel and reinforce its weaknesses.

This book should get an HTML/CSS developer who’s not afraid to dip their toes into some PHP up to speed with customising a drupal site, and its worth considering if you’ve been mostly building static sites or customising wordpress and need a content management system with a wider range of features. Unfortunately it’s still fairly weak structurally, and you may well find yourself needing to combine it with quite a bit of online documentation to properly cover the topics under discussion.

Disclaimer: I was sent a copy of this book for review by the publisher. You can find it at packt publishing, amazon US, amazon UK and all sorts of other places.

Recommend this post:

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

 

Generating an accessible tag cloud with drupal

23 November 2007 (12:32 pm)

By James Stewart
Filed under: Notes, Snippets
Tagged: , , ,

A couple of months ago I found myself needing to generate a “tag cloud” in drupal. The contents of the cloud would be all the children categories of a container and as is the norm with tag clouds it needed to display those children at varying sizes based on how popular they are. I looked around at the existing options but none fitted my requirements in how they integrated with the category module, or producing semantically helpful html.

So I rolled my own. It’s a quick module that just provides a few simple utilities. The cloud is initially generated as an unordered list, with the number of nodes matching each tag included in brackets, eg:

<ul>
  <li><a href="/node/1" rel="tag">tag one (5 entries)</a></li>
  <li><a href="/node/3" rel="tag">tag three (8 entries)</a></li>
  <li><a href="/node/2" rel="tag">tag two (2 entries)</a></li>
  <li><a href="/node/6" rel="tag">tag six (4 entries)</a></li>
</ul>

There’s then a jquery function, called on document load, that works through the list, hides the content in the brackets, and changes the size of the text based on the tag’s popularity.

You can include it in a page by calling:

< ?php tagcloud_include($container_id); ?>

within your theme. I’ve tested the module against drupal 4.7 but it should work fine in 5.x (and I guess 6.x).

I don’t have time or the inclination to do much more work with this module, or to provide support for it, but it seemed worth throwing out there in case anyone else wants to build on it. If you’d like to adopt it, let me know and we can collaborate.

If you’re interested, you can get the tarball here.

Recommend this post:

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

 

It’s surprising given drupal’s popularity that there aren’t more books covering it in detail. Site launches and contributions by the likes of lullabot and bryght have pushed the CMS’ profile and recent releases have emphasised the Web 2.0 potential, but a quick look at amazon reveals only four related titles. Of the four, Pro Drupal Development is definitely the most developer focussed.

This isn’t a book for a drupal newbie. Going in you’ll want to have spent at least a little time setting up a drupal site or two, and while there’s no need to be a PHP guru the authors do presume you’re not going to need help understanding their code samples. They focus on drupal’s internals, with a lot of time spent writing modules, understanding the user, node, menu, theme and related systems, and a little attention for performance optimisation.

There’s a lot of ground to cover and most chapters are short, giving just the essentials on each area. You’ll probably want to pause from time to time to try out the code samples unless you’re already experienced at writing drupal modules. Having written a number of modules and run into various problems I found I was able to focus on the new information and how it would have affected my approach, but if this is new ground the structure of the book may make it rather overwhelming.

The writers are keen to encourage their readers to read the book in order, and some chapters certainly do build on their predecessors, but the real strength of this is likely to be as a reference guide. A quick once-through will help newcomers to module development get a sense of how everything fits together, but chances are you’ll then want to refer back when you actually encounter problems that a given chapter can help with.

I was disappointed not to see more coverage of testing drupal code. As I mentioned yesterday, the lack of attention paid to automated testing in the drupal community frustrates me and it seems that for a book like this to not to provide some coverage of sensible testing regimens is a missed opportunity. Similarly, it would be really good to have some coverage of deployment tips, particularly relating to upgrading active sites. Both of those seem to me like core topics for any book purporting to provide a guide for professionals, but the priorities of the book mirror those of the drupal community where neither topic appears to be a significant concern.

For any experienced developer who needs to get to grips with the insides of drupal and/or write custom extensions, this book will be invaluable. The style won’t suit those looking for a broader scope or lengthier tutorials, but it will help you get to grips with each of the major components quickly and provide enough information to set you on your way. Hopefully it will also trigger further writing about drupal, which may cover more ground and help developers bring some other vital practices to their drupal work.

Disclaimer: I was sent a copy of this book for review by the publisher. You can find it at apress, amazon US, amazon UK and all sorts of other places.

Recommend this post:

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

 

As I’ve indicated here a few times, when announcing site launches and offering a few hints and tips, I fairly frequently find myself working with Drupal but have long had reservations about doing so. What I’ve so far avoided doing is going into much detail about why that would be, what those reservations are, and so on. But now I’m working on a review of a Drupal book and so it seems appropriate to lay those cards on the table and look at the details on them. It seems easiest to do that by comparing with the framework I do most of my development in: Ruby on Rails.

As ever with technology comparisons, just like any other sort of comparison, a lot of my preference for rails boils down to a combination of taste and experience. I’m also well aware that I’m comparing unlike things. Rails and Drupal set out to solve different problems, and so obviously take quite different approaches. That doesn’t mean, however, that developers aren’t often left choosing between them as the boundaries are blurred and there is significant overlap between their respective domains.

I’ve seen plenty of bad ruby code, but proportionately I’ve seen a lot more bad PHP, and as a PHP-based solution Drupal inherits some of that baggage. Drupal has pretty good support for a wide range of cutting-edge ideas and tools, but by and large the Rails community has seemed much more clued-in to what’s happening at the forefront of web development. That may of course change as the Rails community continues to transition from being chiefly early adopters to a much more mainstream crowd, but it marked my early impressions of the framework.

A case in point is the integration of automated testing in Rails. There is some community support for automated testing in Drupal (primarily through the simpletest module) and there are plenty of Rails projects that lack tests, but there is a strong focus on Test-Driven and Behaviour-Driven development in the Rails community, and the combination of Rails’ object orientation, simple rake tasks and fixtures/mocks makes it very simple to write a solid test kit.

Testing is complicated by the hooks system in Drupal. Hooks are a powerful feature, allowing any module to broadcast and listen for a variety of events and respond appropriately, but it can be difficult to know what order modules will receive those events and so you end up performing a variety of contortions to make sure your responses are given the appropriate weight. Arguably Rails’ layers of filters and plugins can introduce similar complications and I’ve certainly spent quite a bit of time tracking down performance hits coming from rogue filters in plugins and engines, but so long as inheritance is properly handled it’s not all that difficult to do a little introspection to make sure everything’s in its right place.

The fact that Drupal relies heavily on web-based configuration makes it easy to put a lot of power in the hands of admin users, reducing the reliance on a developer, but it also makes upgrades and deployments a more complex business. When I add a new module to an existing Drupal project I usually find myself noting down the steps I take to configure it in my development and/or staging environments so that I can repeat that process in production. In a Rails project I’d write a migration and set up capistrano to run that migration when I push my new version live, significantly reducing duplication. The Drupal approach may be simpler for non-developers, but as a developer I frequently get frustrated at the repetition of tasks that could be so much easier.

That issue is one of the key things pushing me away from the nice-in-concept CCK. Adding new content types to a site through a web interface is an appealing idea, but it’s a pain to have to work out how that changed things in my database to produce a script, or to have to repeat a manual process. Since I know how, I’m much more likely to produce a module for my new content type, simply because I know that deploying that is a much quicker process.

One reason it’s been fascinating reading the Drupal book I’m currently reviewing is that books on Drupal are so thin on the ground. That’s a real shame as while there’s a lot of content on Drupal online, it’s not really been well organised for experienced developers wanting to build serious solutions who aren’t already intimately involved with Drupal. By contrast, while the Rails books are mixed in quality the best ones not only get you up and running fairly quickly, but provide a good entrance to exploring the internals and writing effective extensions. That’s not necessarily a reflection on the core projects themselves, but both online documentation (where, admittedly, Rails is still lacking) and books make a significant difference to the developer eco-system and quality of the solutions that are likely to be built.

I don’t mean to sound too negative, and I’d love to receive comments showing me how to address the shortcomings I perceive. I’ve built sites I’m proud of on top of Drupal, and where their focus is a good fit for Drupal’s core features or mainstream modules it’s been a very good solution, providing a suite of content management tools at very little cost. But as soon as there’s serious custom development to do, those advantages tend to dissipate pretty quickly when set alongside the advantages of Rails for agile, regularly upgraded and well tested solutions.

Recommend this post:

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

 

Available for projects

7 November 2007 (4:06 pm)

By James Stewart
Filed under: Announcements, Meta
Tagged: , , , , ,

With a few projects coming to an end it turns out I have some time on my hands that I could do with filling with some paying work. I’m an experienced web developer, having been building sites and applications for eleven or twelve years now. I prefer to work with Ruby on Rails, and have been doing so for two years, but am comfortable in a range of environments and want my tools to match the project as well as possible. I frequently find myself working with drupal, and as an eight-year PHP veteran, that’s okay.

I’m particularly passionate about helping charities, music organisations, and magazine publishers make use of the web as effectively as possible. I can help such organisations work out how what they do in other environments translates to the web, and then to build the tools to make that happen. I prefer nuance to buzzwords, but I can throw around the appropriate Web 2.0 terms if I have to.

(and if you don’t fit in that list but have a project you think I might find interesting, I’m still interested in hearing from you)

I’m used to working solo, or in a small team, and have experience of leading teams as well as being a member. I’d prefer something in or around London, but usually work from home and am quite open to remote working.

I’ve got three, or maybe four days available for the next couple of months. You can reach me at james@jystewart.net to find out more.

Recommend this post:

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

 
« Previous PageNext Page »