6.x

Module Monday: Text Formatter

By Jeff EatonArticle1 comment

CCK in Drupal 6 and FieldAPI in Drupal 7 give site builders a variety of structural and formatting options for carving out new content types. Multi-value fields in particular allow a node or other content element to store lists, collections of links to taxonomy terms, and more. The downside, of course, is the formatting: by default, Drupal's HTML output for multivalue text fields is a big old bag of DIVs. Taxonomy fare a bit better: they're output as proper HTML lists, a semantically proper approach. Both still require considerable CSS wrangling if you're interested in displaying multiple values simply, however. And that is where the Text Formatter module comes in.

Screenshot of administration screen

Text Formatter is a simple CCK/FieldAPI formatter for Drupal 6 and 7 that outputs multi-value text and taxonomy fields as comma delimited lists, or customizable HTML lists. It can do a few other fancy formatting tricks, as well: the last item in a comma-delimited list can be preceded by a grammatically correct 'and', and comma-delimited lists can be closed with a period. Ordered and unordered lists can also be chosen, and a custom CSS class can be specified for a particular list if you're interested in targeting special CSS rules or JavaScript behaviors. The module even allows you to format single-value long text fields as lists if they contain multiple lines of text. read more »

A Quick Guide for Code Reviews

By Andrew BerryArticle2 comments

Code reviews are an essential part of the software development process. Often a code review is considered to be a distinct process and kept separate from day-to-day development. At Lullabot, we consider code review to be a critical component of any development - just like QA, automated testing, and documentation. Code reviews are an acknowledgement that every developer is a human being, and humans make mistakes. No matter the skill or background of a developer, reviewing their code can only improve the final product.

Of course, code review is an integral part of Drupal development as well. The community convention is that at least two people (and often many more) should read and understand code for it to be considered for inclusion in Drupal. While contributed modules don't often have the resources for full code reviews of every patch, be sure that any module author would love reviews of their code.

What are the key components of a code review? While this is by no means a comprehensive list, here are some of the items I look for when reviewing code. Feel free to post your favourite code review tactics in the comments below.

The Story of the Code

All code committed to a project should be an atomic unit that describes:

  • Why the change was made.
  • What lines of code were changed, and how the new code works.
  • How to verify that the change actually worked.

Module Monday: Konami Code

By Jeff EatonArticle14 comments

Here at Lullabot Headquarters, we try to make sure that each week's Module Monday article highlights a lesser-known tool that's simple, useful, and efficient. In honor of the holiday season, though, this week will show off a Drupal module that's 100% fun: Konami Code!

If you played video games in the 80s, you might remember the infamous secret code that could be entered on the first screen of Contra and other games produced by Konami. An entire generation of gamers learned that up-up-down-down-left-right-left-right-b-a was the key to eternal life, and more recently the code was the key to activating east eggs on web sites like Facebook.com and Marvel.com. Now, thanks to the Konami Code module, you can hide the easter egg of your choice on any Drupal site using the same key combination.

Screenshot of the Konami Code module's configuration screen read more »

Module Monday: Premium Content

By Jeff EatonArticle11 comments

Drupal's node access system provides a basic framework for hiding nodes from unprivileged users, and a bevy of third-party modules us it to restrict access based on content type, group membership, and more. Sometimes, though, you don't want to hide content entirely. If you're teasing visitors with a glimpse of premium content, you don't want nodes to be completely hidden. What you need is the Premium Content module.

Based on the venerable Premium module for Drupal 4.7 and 5.0, Premium Content leaves node teasers untouched, ensuring that content shows up as normal on listing pages. When a user who doesn't have permission to view premium content visits the node's full page, however, they get a message prompting them to register or upgrade their account.

Screenshot of premium-access content

Premium Content ships with automatic support for two common "premium scenarios." Archival mode leaves all nodes publicly visible when they're created, but automatically marks them as premium once they're two weeks old. "Embargo" mode keeps content premium when it's posted, but releases it to the public after two weeks. Administrators can customize the time periods for those automatic changes, or switch to manual mode, allowing authors to designate individual nodes as premium when they're created. read more »

Module Monday: Absolute Messages

By Jeff EatonArticle4 comments

Drupal's assorted status and warning messages give users and administrators important information about what's happening on a site. They're a bit dull, though, and can easily blend in with the rest of a site's content. In addition,while most Drupal features provide copious hooks for developers to tweak, there's no simple way to hide some messages and show others, alter the text of a given message, and so on.

Absolute Messages fixes that, layering some snappy display options onto Drupal's normal message system and giving developers a set of convenient hooks to manipulate messages while before they're displayed.

Screenshot of Absolute Messages in action

The most visible change once you've installed Absolute Messages is the appearance of Drupal's system messages. They appear at the top of the screen, in color-coded boxes with their own 'Dismiss This Message' close boxes. The style is modeled after the popular Stack Overflow site, and it duplicates some of the site's behaviors as well. Long messages can be collapsed to just a few lines, expanding when the user mouses over them, and normal status messages can automatically close themselves after a few seconds.

Behind the scenes, these rules can be configured for each type of message -- Status, Warning, and Error -- ensuring that important notices don't go away while a user isn't looking. read more »

Module Monday: Panelizer

By Jeff EatonArticle4 comments

When it comes to designing customized layouts and complex content-rich pages, few Drupal modules can match the flexibility of Panels. It shatters Drupal's traditional "Region/Content/Blocks" divide, giving site managers the ability to build custom layouts and enforce consistency across different types of pages.

Unfortunately, the "variations" system that Panels and its companion module Page Manager use can be cumbersome; developers and advanced site builders can master it, but managing huge numbers of different layouts can be a pain. This is particularly noticeable when each individual node on a site, or even of a particular content type, needs to have its own special layout or mix of page content. Wouldn't it be great if there were some way to give some editors and content creators control over the Panel layouts for just the nodes they create? That's exactly what the Panelizer module does.

Screenshot of Panelizer settings screen read more »

Module Monday: Maxlength JS

By Jeff EatonArticle4 comments

Text fields built using Drupal's FormAPI have always supported a "Max Length" property; set it, and Drupal will kick back an error when someone submits too much data in the form field. CCK and FieldAPI support that property as well, allowing you to specify just how much text a user can enter into the fields you've defined. However, the standard Drupal "error on submit" behavior can be annoying for end users who type their novel only to see errors when they submit. Enter Maxlength JS, a simple module that adds jQuery frosting to the maximum-length cupcake.

Screenshot of MaxLength settings

Configuring the module couldn't be simpler: turn it on, and every CCK or FieldAPI text field will get a new "Maxlength JS" option in addition to its normal "Max Length" field. Enter in a number here, and the module will add a client-side character count timer to the field, telling users exactly how much space they have left. If you're defining your own form fields in a module, you can get the same effect by setting the #maxlength_js property on your own form fields. If the MaxLength JS module isn't enabled, the property will have no effect and users will get the default Drupal behavior.

Screenshot of a MaxLength restricted body field read more »

Module Monday: Select or Other

By Jeff EatonArticle5 comments

Drupal's FieldAPI (called 'CCK' in Drupal 6) gives site builders a great set of tools for customizing node editing forms and other input screens. Even for simple text fields, it provides a set of useful widgets like select boxes and radio buttons for choosing between existing options, and text fields for entering in custom values. If you need both of those at once, however -- a list of canned options, and the ability to enter in a custom value as well -- you're out of luck. Unless, that is, you install Select or Other module.

Choosing the Select Or Other widget read more »

Module Monday: CCK Blocks

By Jeff EatonArticle8 comments

Put your fields in their place

Drupal gives site builders and designers a lot of flexibility, but the simple task of moving part of a node's content out of the main content region can be shockingly complex. Tools like Panels, Display Suite, and custom theming tricks can all get the job done, but for simple applications like putting attached photos into a sidebar, they can be overkill. Enter CCK Blocks, a simple little module that does just one thing: stick your CCK and FieldAPI fields into configurable blocks!

Screenshot of the field display settings page

Setting up CCK blocks takes a few steps; on each Field's configuration screen, you can check off the "expose this field as a block" option. Once that's enabled, a new block containing that field's content is available on the block administration page. Using the Field Display Settings page, you can also change the formatter and formatter options are used to display the block.

One of the common use cases for the module is creating an "Author bio" or "Notes" text field, hiding it on the content type's Full Page mode, and enabling the sidebar block. When you view a node's full page, that field will appear in its own block in the region of your choice.

Screenshot of Drupal's Article Image field displayed in a block read more »

WWE & Lullabot Tag Team A Drupal Relaunch

By Jeff EatonArticle19 comments

We're proud to announce that World Wrestling Entertainment, Inc. (WWE) is now running on Drupal! For the past year, WWE and Lullabot have worked closely to design and build a flexible, scalable platform for the company's site and its fans. With 200 million page views and more than six million unique visitors each month, WWE.com's peak traffic is higher than ABC.com, CBS.com, NBC.com, NASCAR.com, PerezHilton.com, NHL.com, and UFC.com -- combined!

Lullabot's work on the site was led by Jeff Eaton, project managed by Rachel Scott, and executed by developers David Burns, Matt Kleve, and Blake Hall. Beginning in early 2010, the team worked with WWE to assess the state of their existing platform, their future plans, and the critically important production needs of the WWE in-house content team. Over the following month, a discovery audit was created that served as the blueprint for the migration project to follow. read more »