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

Debugging with PhpStorm (Including Drush)

I recently made the switch from another (several) code editors to PhpStorm based on the recommendations of several members of the Drupal community - not to mention all the postive things I've heard about it on IRC and various other places.

My main motivation for making the switch was the ability to have a integrated debugger - both when running Drupal in a web browser and via Drush. While there are plenty of resources online demonstrating how to set up the debugger, I found that I needed to do a combination of things to make it happen

Re-ordering Views Attachment Displays

If you have a Drupal 7 view with more than one attachment display, it is not super-obvious how you can reorder the displays. When you create a new attachment display, you can choose the display to attach the attachment display to as well as the position ("before", "after", or "both").

But what if you need to attach two attachment displays "before" another display - how can you control the order of the two attachment displays.

it's actually quite easy once you know how - in the view's "edit view name/description", there is a "reorder displays" option. Click it and behold!

Drupal 7 Check for Available Updates Solution

On a Drupal 7 website's "Available updates" page (admin/reports/updates/update), if and when you request that Drupal manually check for updates (of modules and themes), it can sometimes fail to get available update data for most or all of the projects, regardless of how many times you retry the process. The problem is caused by errant records in the cache_update table in the Drupal database, which apparently are not removed by the update request.

Arbitrary "OR" SQL Queries

I was working on a Drupal migration project today using the Migrate module where I needed to import only select user roles from the source (Drupal 6) database.

The Migrate module allows for a custom query to select only the user roles that need to be imported. In my case, the two roles I wanted to import had role IDs of 4 and 6. So, how do I write a query using the Drupal Database API to do this? Turns out there's a pretty elegant answer. Rather than writing something like:

Drupal Text Formats and Content for Test Nodes

When building a Drupal-based website or theme, you will invariably create some test nodes of a content type that has at least one text area field. You should then add some example text, to see how those fields will look on the website. But beyond those nodes focused on styling, you may find it necessary or advisable to create a large number of additional test nodes of that content type. When you begin this process, you may wonder whether it would be best to add placeholder text (such as the venerable "Lorem ipsum") or leave those fields empty.

Filter a view based on empty Imagefield

Turns out there is no filter that asks wether or not an imagefield (or filefield) has a value. I came across this tip on Drupal.org. The recommendation was to use a relationship, and then choose "Require this relationship" to act as a filter. Pretty cool.

So assuming your imagefield is just called "Image", here is the walkthrough:

  1. Add a new view of type "node"
  2. Add one or more fields (I assume you want to include the image field) in the normal way

When Drupal's Available Updates List and Update Pages Disagree

Drupal website developers and administrators benefit from its built-in feature to periodically check if any of the enabled modules and themes are out of date. Drupal performs this check daily or weekly, when its cron job is run, automatically. If there are any modules or themes in need of an update, then on the admin area's modules or themes "List" page, you will see the notification: