drupal 7

How to update a Drupal 7 website with Drush (notes)

As a brief “note to self,” this is how I just updated a Drupal 7 website using Drush. Please note that the output of some of the commands below refer to early versions of Drupal 8, but these commands also work with Drupal 7.

First, do these things:

Wim Leers’ articles on Drupal 8 Page Cache and performance

Wim Leers has at least three good blog posts on the Drupal 8 “Page Cache” and performance, which promises to be much better than Drupal 7 performance. Drupal 8 now has page caching enabled by default states, “Drupal 8 is now between 2 and 200 times faster than Drupal 7 for anonymous users.”

Drupal 8’s Dynamic Page Cache discusses D8’s Dynamic Page Cache. As the article states, “The Page Cache module only works for anonymous users, the Dynamic Page Cache module takes that a step further: it works for any user.”

renderviz: tool visualizing Drupal 8's render tree provides a few more details, and also provides a demo of the cool Firefox Developer Tools 3D view. The image I show comes from that page.

As I wrote in Huge Drupal 6/7 Boost module performance improvements, the Boost module for Drupal 6 and 7 makes this website render pretty fast, and it sounds like Page Cache is a replacement for Boost in Drupal 8.

Drupal 7 - A Rails-like approach for Drupal form and module development

Looking for a Ruby on Rails like approach for Drupal 7 form and module development? If so, I may have just the tool you're looking for.

As you can see in the video below, I show how I can generate Add, Edit, Delete, and List forms for a Drupal 7 project I'm working on in four minutes, or one minute per form. Of course there's a little more work to be done, but the code-generating approach I've taken is exactly what Ruby on Rails and CakePHP did the last time I used them.

Drupal form default input focus

Drupal form FAQ: How do I get default input focus on a Drupal form field (presumably a form textfield)?

There may be a better way to do this, but here's what I just did to get default input focus on a series of Drupal form 'add' and 'edit' pages. I just included the following Drupal form suffix definition on any form where I wanted to control the default input focus:

Handling Drupal SQL exceptions (db_insert, db_update, db_delete)

While developing a Drupal module, I just ran into a situation where it may be common for users to generate SQL exceptions. I have a 'unique' limit on several of my database tables, essentially saying that certain name fields must be unique for the current project. As you can imagine, it's extremely easy to enter a duplicate name, and while doing a SQL INSERT that can easily lead to a SQL exception.

As a result, I dug around and found a way to handle SQL exceptions in Drupal queries. My current problem is with a Drupal 7 db_insert query, and I handled it like this:

A Drupal 7 SQL cheat sheet

I'm currently developing a new Drupal 7 application (technically built as a new Drupal module), and as I'm building the application, I've made notes on database queries I've made.

The approach I'm taking is to use the following Drupal SQL query functions. As you can see from the function names, there are now different Drupal functions for each query type:

25+ Drupal form and module programming examples

This page serves as an index to all of my Drupal module, form, and databases tutorials and examples. In an effort to help supplement the documentation on the Drupal.org website, over time I hope to have good examples for every Drupal module and form problem you'll run into.

A Drupal 7 SQL DELETE example

Drupal 7 SQL FAQ: How do I perform a SQL DELETE query in Drupal 7?

The short answer is that you use the Drupal 7 db_delete function, like this:

  ->condition('id', 10)
  ->condition('user_id', 5)

This example assumes that your database fields are named 'id' and 'user_id', and the values of 10 and 5 are the values in your database table you want to delete. If you just want to delete by id, your query is simpler, like this: