Drupal tips and tricks

The small things that make life easier with Drupal

Speeding up international Drupal versions

Submitted by Frederic Marand on

Would you like your non-english Drupal site to be more responsive ? I just found two-minute hack to speed it up, by a factor of four on the new Riff hosting. Here's how.

While revising devel.module in order to update the french translation, I noticed the queries performed by locale() took on the order of 20ms to be performed, and there are a whole lot of them on most pages when locale.module is enabled.

Since this seemed abnormally slow, I looked at the structure, and saw why. The current MySQL code goes:

Themeing the search form

Submitted by Frederic Marand on

In the recently introduced Drupal RC2, a pair of new functions have appeared: theme_search_block_form() and theme_search_theme_form(). They replace the ephemeral (some said "Easter Egg") theme_search_box() appeared and disappeared between RC1 and RC2, and raise important issues for themers.

Ideas for Drupal: trapping obsolete functions

Submitted by Frederic Marand on

The recent removal of the quasi-official node_validate_title() function from 4.7 causing various errors with contrib modules, I wondered whether there wouldn't be a way to trap such errors in a way that would be helpful to newbies, instead of the current situation where all they get from their newly haphazard drupal install is a PHP fatal error.

The idea, then, is to register obsolete functions in some form of legacy maintenance module, to generate a useful help page pointing the user to a doc page on drupal explaining why there is an error in his configuration and what he should do. In node_validate_title()'s case, the help is a bit succinct: http://drupal.org/node/22218#node_validate_title.

Drupal admin: deleting many nodes

Submitted by Frederic Marand on

Ofttimes, when developing a site, you can be led to create or import a large number of custom nodes, for instance flexinodes, only to have to delete them later on. Doing it by hand in admin/content is inconvenient when the number of nodes is large, and for custom nodes like flexinodes, the exact entries to delete in the various Drupal tables may not be obvious. Time for a workaround.