Learn Drupal with tons of focused Drupal tutorials at Build a Module.com

newsletter icon

twitter icon

rss icon

Articles

07/20/11

Many folks interested in Mastering Drupal are looking for videos.

I decided not to create a full screencast series as part of this site, but our team is still producing videos periodically and making them available for free. However, since this site was started there have been two new companies launched that offer Drupal vides.

BuildAModule.com - Drupal videos by Chris Shattuck

Chris Shattuck, a really great person and competent Drupal developer/themer/site builder, created BuildAModule.com. This site has tons of videos broken down into short, digestable chunks. If you need to learn one specific thing you can watch just that video. They are also thoroughly screencasts: you see Chris' screen. He's great at using on-screen tools to highlight his mouse and the item he is working on so you can follow along.

The pricing is very reasonable between $23 and $29/month for online options or $29 to $399 for his DVDs. Note that his DVDs are actually full of video files for playing on your computer meaning that they are much longer than "DVD" might imply.

Drupalize.me from Lullabot

And of course a second option is Drupalize.me from the Lullabots. They have combined their tutorial videos, DiWD videos, and some site-specific videos to create a large library with a diverse set of presenters.

This creates for an interesting presentation of content because it mixes up medium length purpose focused material like "how to theme in Drupal" with a presentation style instruction where you might not be able to see the screen but the presenter themself might be more interesting.

Pricing on Drupalize.me varies from $35/month to $45/month depending on your commitment.

What do you think? Do you subscribe to either one of these sites? Are you getting videos from somewhere else?

3
04/27/11
6.x, Developer, Intermediate
Often you need to load external JavaScript resources into a Drupal page. Unfortunately those can be from external servers that are slow. Even if the servers are fast, it is great to be able to take advantage of Drupal's JavaScript aggregation to make it a single HTTP request for the JavaScript file instead of multiple. The attached starter module is useful to create a local copy of external JavaScript files. This is a task that is really site specific. There are visibility rules and lists of modules to maintain. So, rather than creating a contributed module for it I'm presenting it here as a tutorial. You can also download the code for Drupal 6 as a .tgz. There are three functions in this starter module.

List out your files in customlocaljs_files

This function is just a piece of configuration to let other functions know which files they are dealing with.
<?php
/**
* A helper function to list all your external js files.
*/
function customlocaljs_files() {
  return array(
   
'example1' => 'http://example.com/number-magic.js',
   
'exampleb' => 'http://example.com/fun-with-advertising.js',
  );
}
?>

Download and Add the JavaScript in customlocaljs_init

This function shouldn't need any tweaks unless you want to modify exactly which pages on the site the JavaScript should be added to.
<?php
function customlocaljs_init() {
 
// If you want you could also do this in a node_api or wherever it makes sense.
  // Only do this in your init if that's where you need to add the js.
 
$directory = file_directory_path() .'/customlocaljs';
  foreach (
customlocaljs_files() as $key => $url) {
   
// First make sure that the file is available locally.
   
$file_destination = $directory .'/'. basename($url);
    if (!
file_exists($file_destination)) {
     
$result = drupal_http_request($url);
      if (
$result->code == 200) {
       
// Check that the files directory is writable.
       
if (file_check_directory($directory, FILE_CREATE_DIRECTORY)) {
         
file_save_data($result->data, $directory . '/' . basename($url), FILE_EXISTS_REPLACE);
        }
      }
    }
   
// This actually adds the file to the page.
   
drupal_add_js($directory .'/'. basename($url));
    }
  }
}
?>

Delete the files every 24 hours: customlocaljs_cron

The final purpose is to delete the files every 24 hours. This is important since the code that downloads files only goes to get them if they aren't available.
<?php
function customlocaljs_cron() {
 
// Redownload the files every day.
 
if (time() - variable_get('customlocaljs_last_cache', 0) >= 60*60*24) {

   
// You have to create this file locally.
   
foreach (customlocaljs_files() as $key => $url) {
     
file_delete(file_directory_path() .'/customlocaljs' . '/' . basename($url));
    }

   
// Clear aggregated JS files.
   
if (variable_get('preprocess_js', 0)) {
     
drupal_clear_js_cache();
    }

   
variable_set('customlocaljs_last_cache', $_SERVER['REQUEST_TIME']);
  }
}
?>
And that's it! Once you've done this you should of course make sure that you are running cron and then bask in the glory that is locally aggregated javascript files.
0
10/09/10
6.x, Developer, Advanced

For a recent project we needed to do a fair bit of work with locations, maps, and distances:

  • Associating retail stores with latitude/longitude
  • taking users and finding the nearest store based on the entry of a postal code
  • showing nodes in a nodereference based on distance.

Solving the last two of these things ended up being interesting enough that I wanted to share them with you.

0
03/08/10

When you're learning Drupal it can be really helpful to read how other people have accomplished the same thing that you're trying to do.

Drupal Tutorial and recipes handbook

The Drupal.org Tutorials handbook is a great resource. It contains hundreds of pages showing how to do all sorts of different things.

Learning from Drupal Case Studies

Another great tool is the Case Studies where people explain how they built a specific site.

Similarly, the recipes area is full of great tips for how to make Drupal achieve certain features.

0
01/01/10
6.x, Themer, Book, Intermediate

I recently read Front End Drupal (buy on Amazon, companion site) and wanted to share some of my favorite points, some parts that could be enhanced, and some ideas I have for ways to expand it in a future edition. I've known Emma Jane Hogbin and Konstantin Käfer for some time now through the Drupal community and respected their work. So, I was quite interested to see how they would do in book medium: it's some impressive work.

In my experience training and writing books, one of the hardest things is picking the right audience for the book and then making sure that your book has support for people above and below the level of your ideal audience. You need sidebars to help explain details on advanced topics and good section titles so that advanced people know when to stop skimming over the things they know and start reading again.


This photo shows a nice screenshot, some helper explanation text, and my next read in the background.

Favorite Parts of Front End Drupal

There are several general things and several specific things that I liked about this book:

  • They cover not only "Front End Drupal" but also some best practices for Web design and information architecture in general.
  • Mixed among the details of template files and overrides is solid advice about how to configure Drupal's core and several contributed modules so that a reader who is new to Drupal will learn much more than just theming.
  • They cover advanced Javascript and jQuery concepts in a way that made it accessible to me, even though I've struggled to fully embrace the language for about 10 years now!
  • They provide guidance for converting Wordpress and Joomla! themes to Drupal, which is something I've never seen covered before (page 101).
  • They give a nice example of using the preprocess hook to suggest template names based on the page alias - something which could come in quite handy on many sites (page 134).
  • Chapter 5 talks about Views almost too briefly - but then the topic is covered in more detail in chapter 8. This book is not, though, a sufficient guide to the topic of Views (and that probably makes sense).

Some Suggested Enhancements

One area where I was a little disappointed was some security related topics. In general the book stays at the theme layer which forces some compromises. There is also some advice on security functions that incomplete. Of course, I'm a little more picky about this topic as the author of Cracking Drupal the first book to tackle the subject of security in Drupal.

  • The book covers check_plain and check_markup as the two text filtering functions in Drupal. In fact there is at least one other common one - filter_xss_admin() - which should be used to filter text entered by the "admins" of a site and which should only be filtered mildly.
  • On page 206, among other places, they cover ways to hide fields in a form. It's important to note that this is only cosmetic and not a "security" measure because it is quite common for admins or end users to switch the theme in which case the form theming to hide fields would be completely lost. In my opinion this task is best left to a module and the theme_form_id_form function should only be used to re-order form elements or add some extra HTML.
  • The l() function, discussed on 226, is shown with a check_plain around the text. This is unnecessary because the l() function performs that filter itself by default. Better would have been to explain the use of the 'html' => TRUE option and how to sanitize text if you use that optional argument.

These are minor nits, though, and overall I think the book is great.

Room for expansion in Front End Drupal

Aside from being updated to cover newer versions of Drupal, I think it would be great to cover a few more contributed themes and discuss the best strategies for "sustainable theming" that has been a hot topic in Drupal recently. I also would have appreciated more examples of writing jQuery components in chapter 11. The one example - a slideshow component - was hard for me to really get excited about so I had a hard time following the explanation. One idea: I would love to see an example of modifying the DOM by adding content into a page based on a user clicking on a link or form element.

As Dries said, "For Drupal to succeed, we need books like this." With so many Drupal focused books available these days it's hard to find genres that still need to be covered, but this book really filled an important gap.

The affiliate links in this article are from the Drupal Association

0
12/22/09

The Drupal.org Theme Guide is an amazing section of the handbook. It is one of the best written sections and contains many amazing illustrations to help people understand how to theme Drupal.

0
10/13/09
0
10/13/09
6.x, Themer, Book, Intermediate, Advanced
0