Playing with Frank in the snow last night

Last night it flooded, this morning snow. Hello Boone

Last night we had some epic flooding in Boone last night and this morning I woke up to snow and ice everywhere. Here's some photos from my walk to work.

My favorite beers of 2012

Here's a quick list of some of the best beers I tried in 2012.

Using grep and awk to find the ServerNames of your hosted Aegir sites

This onliner looks at your apache vhost configs (you can also change it easily to work with nginx) and figures out all of the ServerNames your apache instance is listening for.

SITES=( $(/bin/grep ServerName /var/aegir/config/server_master/apache/vhost.d/* --color=none -h | awk '{ print $2 }') )

Drupal 7 and paginating EntityFieldQuery queries

In Drupal 6 creating a paginated query was pretty straight forward, you would use the pager_query and go from there. With the switch to entities in Drupal 7 we have a class called EntityFieldQuery that returns an array of entities based on properties of the entity.

It's really easy to use:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
  ->propertyCondition('type', 'thing')
  ->propertyCondition('status', 1);
$result = $query->execute();

And there you go, as long as the array in the $result variable has the 'node' key you should be good to go on to entity_load() and start using the data the class returned.

Adding pagination to this query is really simple, all you have to do this:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
  ->propertyCondition('type', 'thing')
  ->propertyCondition('status', 1)
$result = $query->execute();

and when you're rendering the list:


Which renders the pager and handles everything else. That's pretty much it.