Quicktips

DrupalEasy Quicktips are short, focused posts intended to accomplish a very specific goal. Quicktips are exclusively available first via our @drupaleasy Twitter account.

Hitting Drush Memory Limit

We love Drush, Drupal's all-purpose command-line tool, for people who can't stand checkboxes. It's fast, efficient, plays nicely with Version Control Systems like CVS, SVN and Git, and even cleans the kitchen sink. However, after moving our DrupalEasy.com site to a new server we encountered a minor snag. When trying to run even the simplest of Drush commands, we were faced with the following error:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 311296 bytes)

I need to change the number of items returned by a view, based on the theme!

A friend recently came to me with the following question:

I have a site that has a mode optimized for low-bandwidth use. Can I change the number of rows returned by a view based on the theme?

The Views 2 API has a function called hook_views_query_alter() which allows you to modify the View object before it pulls the results from the database.

In order to use views hooks, you must create a module that registers itself as using the Views API:

Disappearing Primary and Secondary Menus

I recently was performing some module upgrades on DrupalEasy.com (on a development server, of course) when I was surprised to see that both the primary and secondary links were suddenly missing.

I spent the better part of two hours going through the various modules I had updated, checking and double-checking my theme, and generally pulling my hair out.

Turns out the solution was quite simple. Somehow, the sources for both the primary and secondary links had reset to "No primary links" and "No secondary links" on Drupal's main menu settings page (admin/build/menu/settings).

Help! I'm constantly redirected to my Home page!

Working on an old Drupal 5 site (I was upgrading core), I came across a very odd bug. Every time I submitted a form, I was being redirected to the frontpage of the site. I had recently installed Path Auto and Global Redirect, so I thought one of those could be causing the problem.

With Global Redirect on, when I tried to visit a normal URL with an alias, in this case, node/2 that was aliased to services, I was also getting redirected to the home page.

Setting Checkboxes in Drupal Admin More Efficiently

On some of the Drupal administrative pages, you will encounter a great many checkboxes. This is especially true of the permissions page (User management > Permissions), which starts off with more than six dozen checkboxes for a vanilla Drupal 6 installation. Add a typical suite of contrib modules, and the number of checkboxes increases substantially. As a consequence, you may be forced to manually check or uncheck long sequences of checkboxes, which quickly becomes tedious and time-consuming.

Avoid the Cache with Cache Exclude Module

Sometimes page caching can get in the way of your site's functionality - even for anonymous users. In those rare cases where you don't want page caching used, there's a module that allows you to exclude certain pages from being cached.

The Cache Exclude module has a simple configuration page where you can enter paths and pages on your site where you don't want caching to occur.

It's a great and simple solution to a sometime annoying problem.

Manual Control of ImageCache Cropping with Imagecache Javascript Crop Module

While Imagecache is a stellar tool to automatically create and display resized and cropped images on your site, sometimes a bit more control is necessary.

Imagecache cropping is an automatic process that crops from the center of your image. So, if the most interesting part of your image is in the upper-left, it will most likely be cut off at least partially in the resulting image.

Taking over an un-maintained or abaondoned Project on Drupal.org

Ever downloaded a module and noticed several obvious bugs? Often, you can look in the issue queue for a module and find fixes, code patches, and help with these problems. For certain modules, the maintainer of the code may not respond - he or she may no longer be developing with Drupal, may have changed his or her email address, or any number of other factors.

HTML Filter Side Effects

The HTML Filter that comes with Drupal core is extremely useful - it allows you to restrict the HTML elements that you allow your content creators to use in their posts. If you don't want them including images or JavaScript, no problem. The filter settings allow you to specify exactly what HTML elements they are allowed to use.

Views Bulk Operations Main Admin Content Screen

One of the most actively used administration pages on any drupal site is the main content administration page (admin/content/node). From this page, the site administrator can quickly get a list of all the nodes on their site as well as filter and sort the list in a variety of ways.

However useful you may find this, you may not be aware that the Views Bulk Operations module provides an even more useful main content administration page with the often requested "search by title" filter.