50 Drupal Tips and Tricks

Podcast episode player
0:00 0:00

The Lullabot team celebrates its 50th podcast with a list of 50 Drupal tips and tricks.

Here's the list:

Drupal admin and configuration:

  1. Create a "HTML help" block and assign it to appear on only "node/*/edit" and "node/add/*"
  2. Use the "edit permissions" link on admin/user/roles to get a single column
  3. Use the Firefox Web Developer Toolbar to "Populate Form Fields" on the access page for the admin role
  4. Use "site:drupal.org {search terms}" to search all of drupal.org with
    Google. Set up a Firefox shortcut so you can type "dru [your search]" to
    search Drupal. Also api.drupal.org/apis/{search_term}
  5. When using pathauto to alias usernames, don't let users change their usernames.
  6. Use PathAuto and Path Redirect together to redirect old aliases to the new ones. Search engines will love you.
  7. Use Global Redirect to make sure home page is "/" and current page doesn't have an alias.
  8. When creating PathAuto template, keep uniqueness in mind -- perhaps add a date to your blog and news entries.
  9. Move the "My Account" menu item by creating a custom menu item at 'user'
  10. Use update_status module along with cvs_deploy & cvs tags to manage sites
  11. Use ImageCache to resize images. It's worth the poor u.i. and configuration challenges. Tastes best with ImageField, CCK, and Views.

  12. Turn any CCK type with an imagefield into a photocast with ConTemplate
  13. Use Automatic Node Titles whenever you want to have separate (CCK) fields for first name and last name, but you want the node title to contain the full name.
  14. Use SimpleMenu to remove the need for an admin block on the page.
  15. Set your site in "offline mode" when doing Drupal upgrades, to ensure that your end users are never exposed to any funky errors.
  16. Use locale.module to change English text into other English text. Example: change "Forums" to "Message Boards". Slight performance issue for high-traffic sites. In Drupal 6, there's a new "locale lite" feature to translate only a few pieces of interface text without the overhead of locale module itself. Check the bottom of default.settings.php for more details.
  17. Use views + views_fastsearch to build "section search" or custom advanced search pages


  1. Enable the contributor block on drupal.org. This will give you access to all kinds of useful links, as well as tell you how close we are to releasing Drupal 6.
  2. Check out the Drupal Planet at http://drupal.org/planet to keep up to date on exciting developments and what various folks are working on.
  3. Post suggestions or bugs you find with Drupal or contributed modules to the issue queues, not on the forums. They're much more likely to get attention from developers there.
  4. Check out http://drupal.org/node/10259 for some tips on posting to the issue queue, including how to make a good bug report/feature request, how patches get reviewed, and so on.
  5. Head to http://drupal.org/videocasts to view a categorized archive of various Drupal videos and presentations on a variety of subjects.
  6. Sign up for the security announcements at http://drupal.org/security to keep on top of your updates!

  7. Ninja search #1: Negative words. Eliminate the words you don't want with a minus in front: -Joomla

    Ninja search #2: Content types: type:forum or type:image etc.

    Ninja search #3: Phrase search. Put exact phrases in "", as in "Drupal rocks".


  1. Set up a quick "wireframe" site using Zen or another simple theme. Show this and the HTML it outputs to your web designer before they start working. Point out items like tabs and messages.
  2. Change your administration theme when working on a new theme
  3. Get to know Firebug for ALL front-end development: JavaScript and CSS!
  4. <?php var_dump(get_defined_vars()); ?>inside any template file to see what variables are available.
  5. Create a hook_link_alter() and add a "More..." link to the end of the Teaser text while removing the Read more link
  6. The format_interval() function
    is cool. It outputs "X minutes Y seconds ago", or similar...
  7. Accommodate page caching by substituting dynamic page elements in your theme.
    If the user is not logged in, use absolute values such as "posted on {date}
    at {time}", rather than relative such as "{X} hours, {Y} seconds ago".


  1. Use theme('view', {arguments}) to embed a view anywhere in your theme's template.php or .tpl.php files
  2. Use the custom argument handling code in a View to change anything about a view: filters, number displayed, fields, and of course arguments. You can alter these items with or without conditionals. Change the number of columns in a grid view; change the number of items that appear if the "feed" argument is present; etc... (see #36 to see the view object)
  3. Use "promote to front page" / "sticky" to do other things using Views... see also Views Bookmarks
  4. Use Views + Taxonomy
    to use a custom view for each vocabulary's listing pages.
  5. Use print_r($view) inside the 'Argument code' field of a View to see the view object. see #33 (oops)

  6. Give any number of 'block'-only views the same page URL, and their [more] links will all point to the same page.


  1. Translate your javascript by doing <?php
    drupal_add_js(array('my_module' => array('my_string' => t('My string'))), 'setting')
    ?>Get translated strings from javascript: Drupal.settings.my_module.mystring

  2. Same with urls: <?php drupal_add_js(array('my_module' => array('my_url' => url('node/10'))), 'setting') ?>It's more reliable and less work than using $base_path and Clean URL setting.

Drupal Development and Coding

  2. Many IDEs (Zend, Komodo, Eclipse) will parse Drupal's code base and give you autocomplete and documentation on the function names
  3. Run a local copy of api.drupal.org (using api.module) -- parse contrib modules! Documentation here: http://drupal.org/node/26669
  4. Figure out arg(), you won't be sorry.
  5. Use $_GET['q'] anywhere in your site to get the real Drupal path (not what's in the menu bar)
  6. Find out if the current user is logged in: <?php if ($GLOBALS['user']->uid) {/* the user is logged in */} ?>
  7. In Drupal 6, the contrib Schema module will generate a full-documented list of Drupal's tables. See http://jaspan.com/drupal-6s-self-documenting-database-schema and http://drupal.org/node/184586.
  8. Use cvs annotate to track down the hows and whys of a particular line of code. View a how-to at  http://www.lullabot.com/articles/cvs_annotate_or_what_the_heck_were_they_thinking
  9. Coder module can not only be used to check over code for coding standards compliance, but can also be used to notify you of things that need to be done to your module to upgrade it to the next Drupal version.
  10. On api.drupal.org, you can use the "List references" tab on any function to view where else in the source it's called, as well as what other functions are called by the function you're looking at. This can be helpful if you have a question about how a function is used.

  11. Drush!