Tech Articles

Building a Multistep Registration Form in Drupal 7 using Ctools

This article provides a step-by-step tutorial for creating a custom, multistep registration form via the Ctools Form Wizard in Drupal 7. If you'd prefer to solely use the core Form API, take a look at Building a Multistep Registration Form in Drupal 7, a previous blog post. In the interest of saving time, I'm going to be lifting some text directly from that post, given that there are a number of overlapping tasks.

Why use the Chaos Tools module to build a multistep form? Well, Ctools offers a number of tools that build upon the core Form API, allowing you to create a multistep form faster. This includes providing a method for caching data in between steps, adding 'next' and 'back' buttons with associated callbacks, generating a form breadcrumb, etc.

Introducing Devit

Devit Admin
You have a live website and you need to copy a fresh version of the (live) database onto your local machine for development. Next, you need to run through one or more of these rote tasks:

  • Disable Drupal core caches (page cache, block cache, CSS & JS optimization, etc.)
  • Sanitize user data
  • Update Drupal's file system paths (public, private, tmp directories)
  • Enable email rerouting
  • Update logging and error level settings
  • Re-configure a contrib module. E.g., Secure Site (enable, set permissions, guest accounts).

Does this sound familiar? If so, I have good news! I've created a module that will help you automate that process.

Introducing Writer: A Drupal blogging theme for developers

Writer Theme
My friend and co-acquian, Bryan Braun, recently released a new, beautiful, minimalist blogging theme on Drupal.org called Writer. I'll let Bryan make the official introduction:

"The story is quite simple. I am a front-end developer who blogs. I searched the Drupal theme repository, but I was unable to find a blogging theme designed specifically for developers. So I made one.

This theme was designed using three driving principles:

  • Brutally simple design
  • Fantastic typography
  • Support for code snippets

These principles guided me through the tradeoffs and helped me make various design decisions. Let's get into the details..."

Applescript to add images to Microsoft Word table

This is a bit of a forray into the unknown for me— I don't know a thing about applescript, but I managed to piece this working snippet together from various internet posts. Hope that it helps someone!

This script does the following:

  1. Prompts you to select a folder (should contain images)
  2. Finds the active Microsoft Word document
  3. Find the first table in the document
  4. Inserts first image from folder into row 2 of table
  5. Continues loop, inserting next image into next row

 

Restoring an accidentally deleted Vagrant directory

If you accidentally deleted your Vagrant directory, and you have an orphaned VM sitting in VirtualBox, you can re-associate it with a new VagrantFile. Here's how.

When new VM is first created for a given VagrantFile, Vagrant creates a .vagrant file in the same directory. It contains a JSON array, which stores the Unique ID:

{"active":{"default":"ec426377-dbe6-4be7-4751-766956e44958"}}

You need to re-create this file.

1) Determine the Unique ID for the VM.

To see a list of all Virtual Box vms:

$ VBoxManage list vms

2) Re-create the .vagrant file by adding the appropriate UUID to JSON a array in .vagrant.
3) Recreate the VagrantFile.

DrupalSnippets, an imaginary snippet sharing website

I recently joined the #drupal-dc channel on IRC and asked the following question:

I'm thinking about building a site that would allow people to easily share Drupal code snippets. Does any think that this is a good or bad idea?

I was surprised when @jemond immediately responded with the message that he was considering building the same website. Well then, there must be something to it! One conversation and a few beers later @jemond and I had a plan.

Crowdsourcing Drupalers

The first step of this plan is to ask you, the Drupal community, the same question—is this a good or a bad idea?

This website will be by Drupalers and for Drupalers, so we'd like you to contribute ideas! Please comment with your answers to one or more of these questions:

Field API - Creating your own field formatters

Drupal 7's Field API is amazing—it allows us to easily add fields to any type of entity, and customize those fields with various widgets and display formats. I'm going to walk you through two examples of how you can leverage the Field API to create your own custom field formats.

Example use cases:

  1. You're using the phone field to display phone numbers, but you'd like to customize the HTML output to make it mobile-compatible (click to call).
  2. Your nodes display full addresses via the addressfield module, but you'd like to render those addresses as google maps links.

Let's start at the beginning: you're going to be creating a custom module. Let's call is grasmash.module for vanity's (and sanity's?) sake.

We'll start by letting the Field API know that we have a new field format for it to play with.

Create a "password_reset" resource for Services

Just another quick snippet to add to the Grasmash Services archive.

This will allow you to POST an email address to /your_endpoint/user/password_reset and trigger a 'Forgot Password' email to be sent to the appropriate user.

Snippet Snack: Create Display Suite fields for Flag & Flag Count

I've decided to make a new home for the small snippets that I post periodically: Snippet Snacks. This will be small repository for useful Drupal snippets.

Here's the first one—a snippet that forms a bridge between Display Suite and Flag.

When added to a custom module, this snippet will provide Display Suite 'Flag this' and 'Flag Count' fields for each applicable Flag type.

Adding Flag Count field to Search API Solr index

Just a quick snippet!

Dropping this in a custom module will allow you to easily index values from the Flag module's {flag_count} table in a Search API Solr index.

Pages