Display Views result only when exposed filters are set

Appnovation put a small Views tutorial online today, which hides the results of a View with exposed filters on initial display, when no filter value is set. However, the shown approach has a small performance backdraw: it hooks into the view to discard the result after querying the database. A code snippet on drupal.org avoids this by adding an impossible condition to the query, however it requires the use of a dummy argument and – worse – PHP to be executed in Views' argument handler.

Here's how to do it avoiding above pitfalls (put in custom.module):
 * Implementation of hook_views_query_alter().
function custom_views_query_alter(&$view, &$query) {
  if ($view->name == 'My_View' && $view->current_display == 'page') {
    // Don't display results until at least one exposed filter has a value set.
    $filter_set = FALSE;
    foreach ($view->filter as $filter) {
      // Check if we've found a filter identifier that is set.
      if ($filter->options['exposed'] && array_key_exists($filter->options['expose']['identifier'], $_GET)) {
        $filter_set = TRUE;
    // If the filter isn't set, add a WHERE clause to the query that
    // cannot be TRUE. This ensures the view returns no results.
    if (!$filter_set) {
      $query->add_where(0, 'FALSE');
      // To display a different message (or no message at all) you
      // also might want to adjust the Views' empty text. 
      //$view->display_handler->options['empty'] = '';

Drupal Pathauto: Bilingual stop word list

I've taken some time to update the stop-word lists for the pathauto module.

English (slightly modified module defaults):

German (requires transliteration module to properly convert diacritic marks (Umlaute)):

Hint: since pathauto is currently not language-agnostic, you need to copy both lists into the configuration field ("Strings to Remove").

Drupal should be embeddable

Drupal 6 is currently not easily embeddable into third-party PHP applications, since bootstrapping alters the environment. Needless to say this is bad bad bad. Here's a fairly comprehensive list of modifications applied (in order of execution):
    • drupal_unset_globals() modifies global variables
    • conf_init() changes the session name
    • modifies the session handlers and starts a session
    • drupal_page_header() outputs headers
    • _drupal_bootstrap_full() modifies the error handler, sets a new system locale, and strips slashes from request variables.
To resolve these issues, the integrating code should have the possibility to set a flag that tells Drupal to bootstrap without altering the existing environment.

Drupal Admin Menu: Move out developer functions

Currently, Admin Menu has all those neat little helper functions like Clear cache and Disable developer modules built into the core module. To speed up future development, however, it would be great to have them separated into a dependent sub-module, which could then be developed at individual speed.

Along with my former idea of a site switcher module, this could also include more settings for existing functionality, like the Disable developer modules function, which could expose a list of modules and allow the admin to select which ones to disable, instead of just relying on a hard-coded built-in list.

The following existing functionality could be easily moved into its own submodule, in favor of a slimmer main module:
  • Switch user
  • Devel functions
  • Disable developer modules

-moz-transform on table headers

While working on a new feature for DrupalvB, a Drupal module that integrates the vBulletin forum software with the Drupal CMS, I had to create a rather large matrix table allowing to map Drupal roles to vBulletin user groups. Because the group titles in the table header took up most of the space, I decided to test drive an upcoming CSS3 feature in Firefox 3.5: -moz-transform: rotate(). Here's what the result looked like:

Note: the bad font rendering quality isn't the fault of Firefox, rather it comes from using an old version of Microsoft's Terminal Server which doesn't support anti-aliasing.

Unfortunately, rotating elements just cuts the element out of its current position and draws it with the transformation applied, but doesn't touch the reserved space of the untransformed element. This lets the rotated text paint over adjacent DOM elements. However, since the length of the text is dynamic and thus not known in advance, trying to avoid this would need dynamic calculation of the required padding.