Migrating from WordPress to Drupal 8

Overview

Last weekend I came up short with things to do and with a Drupal 8 release right around the corner I decided to get on with moving my blog across from WordPress. TLDR; It went well :)

Migrate API

Pretty old news at this point for most but Drupal 8 now has Migrate in core. Outside of cores needs for an upgrade path there is an easy to use API for migrating to Drupal from any platform. You could even use it to move between two non-Drupal platforms if you so wanted.

Installing Drush on VentraIP

  1. Install composer
    cd ~ && mkdir bin && curl -sS https://getcomposer.org/installer | php -- --install-dir=/home2/YOU_SITE_NAME/bin --filename=composer
  2. Install Drush
    composer global require drush/drush:6.*
  3. php -i | grep php.ini and then copy the default php.ini into ~/.drush - Make ~/.drush folder if it does not exist.
  4. Remove exec and any other functions drush uses from the disabled_func line in php.ini
  5. Ensure the Composer bin folder is in your $PATH.

Adding a Date Filter to Views When Using Custom Fields

I recently exposed some custom database tables to views using hook_views_data() which as usual was a pleasant experience, until I wanted to use the date filter that the Date module provides. This isn't creating a filter on your field, it's the field in the list that looks like Date (node). The word "node" in brackets is referring to the base table that will be used for the date filter, this allows you to compare multiple dates from the same table. So the hook you're looking for: hook_date_views_extra_tables().

Using the Date Widget with Drupal's Form API

I recently had to use the Date module in a custom booking form that was constructed using Drupal's awesome Form API. Now I'm sure someone is going to come along and prove me wrong but I couldn't find any documentation on the available widget types, form properties or much of anything to be honest. I did find a few wrong examples that were doing some weird hacks like overwriting #process.

Programmatically Create Field Collections in Drupal

I've been working on a pretty big site restructure this week and as part of the restructure I needed to migrate data from some custom database tables into Field Collections to offer a bit more flexibility. Most of the code documented was available on drupal.org but there was definitely a lot of different ways mentioned and no clean cut function for you to reuse. If you're just looking for a cut a paste, here's the code. I will explain it further below but it's pretty well commented anyway.

Installing Ubuntu 12.04 Desktop for Drupal Development

These are the steps I went through to get my new install of Ubuntu 12.04 up and running.

Server Setup

http://klau.si/dev - Setting up phpmyadmin, MySQL, PHP and Apache. If you are exposing Apache to the world then I would advise disabling PHPMyAdmin from remote access. Simply add the following to /etc/phpmyadmin/apache.conf

Configuring Drush on OS X Lion and MAMP 2.0

Today I finally decided to install Drush on my MacBook Air and everything was going great using pear to install Drush until I ran into the error: No such file or directory (trying to connect via unix:///var/mysql/mysql.sock)    [warning] environment.inc:518

Luckily it's an easy fix. Simply create a symbolic link in /var/mysql to /Applications/MAMP/tmp/mysql/mysql.sock with the following code.

sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock

And your done.