Class naming for Javascript development in Drupal

14th Mar 2018

We've settled on what we think is a best practice for class naming for Javascript in Drupal – let me explain what I mean and then talk you through our reasoning.

Read more

Render a Drupal 8 View programmatically (Render arrays FTW!)

12th Mar 2018

Extra quick tip for Drupal developers: Adding views to your page content is now incredibly straightforward:

$content['editor_tools']['view'] = [
  '#type' => 'view',
  '#name' => 'editor_tools',
  '#display_id' => 'embed',
  '#arguments' => [

And that's it! $content is my render array which I'll return and let Drupal render. I suspect most of the bits there are self-explanatory, but in case they aren't:

  • '#type' => 'view' is the magic that lets Drupal's rendering system know that this array represents a view to render.
  • '#name' is the machine name of the view you want to render.
  • '#display_id' is the display ID...
Read more

Quickly creating github pull requests from the command line

2nd Mar 2018

Following on from my feature branching bash script I thought I would do another quick post about a super handy tool I use to streamline my dev workflow a little more (marginal gains and all that).

Hub is a command line tool that lets you do all kinds of clever github stuff without ever having to open a browser.  

All the setup instructions are here - it's pretty simple to get working (if I can do it ...).  I wasn't quite brave enough to alias my git command so I skipped that bit!

Read more

A quick bash script to make feature branching a bit easier

8th Feb 2018

During a typical working day I can easily flip between 15 projects, fixing small bugs or working on various features.  Each flip normally requires a new feature branch, and i found myself repeating myself.  A lot.  I'm a parent so I'm pretty used to this, but in this instance I figured I could probably do something about it - so put together a simple bash script.

Read more