Skip to main content

Drupal Development

Faster Hierarchies with Nested Sets and the Entity Reference Hierarchy module.

In Drupal 7 we used Node Hierarchy module to keep track of a hierarchy of pages. Node hierarchy ties directly to the menu system. When getting a list of all ancestors or descendents, it is a O(n) operation, and at least one site we use it on has a lot of nodes in the tree. Performance was terrible. Add to that it has no notion of revisions or forward revisions, so changing the parent and saving a draft can cause all sorts of issues with your menu. When the time came to update the site to Drupal 8, we took a different approach.

Building a layout system for Paragraphs

A recent Drupal 8 project of ours had some great requirements around it’s landing pages, aimed at reusing existing components in a range of layouts and combinations. Paragraphs quickly established itself as the site-building tool of choice and Flexbox always wins for me as the CSS grid/layout approach, so we looked at how the two could be combined to give the client the flexibility they needed, without over-complicating the editor experience.

Launching an AJAX modal from a WYSWIYG link and customising the response with MainContentRendererInterface in Drupal 8

On a recent project a feature was requested to allow admins to launch some content within a modal window from the WYSWIYG on a Drupal 8 website. The goals were as follows:

  • Open any content on the site in a modal window.
  • Fall back to a plain link for search engines and non-js based browsers.
  • Implement a branded modal design.

This is how we accomplished it.

Custom views filters with Search API and Simple Hierarchical Select

A recent project involved the use of the Simple Hierarchical Select module to input category data for a particular content type. Simple Hierarchical Select provides a clean way of browsing hierarchical vocabularies to easily add taxonomy terms to nodes.

An initially tricky user interface problem to utilise this module with Search API and Views exposed filters was solved using a couple of Drupal 8 plugins and a bit of smart thinking!

Drupal Developer

Introducing Drush CMI tools

Now we've got the experience of a number of production D8 sites under our belt we took the time to consolidate our CMI workflow into some useful drush commands.

And naturally we've open sourced them.

Read on to find out more about our drush CMI tools.

Drupal 8 FTW: Is it a test or is it a form? Actually, its both

As you'd be aware by now - Drupal 8 features lots of refactoring of form procedural code to object-oriented.

One such refactoring was the way forms are build, validated and executed.

One cool side-effect of this is that you can now build and test a form with a single class.

Yep that's right, the form and the test are one and the same - read on to find out more.

Injecting Dependencies into Drupal 8 plugins

As part of our code review process for a current project, it was suggested that rather than calling the static Drupal formBuilder function to insert a form into a custom block, we actually inject the *Form Builder service* directly into the module, and for bonus points also inject the renderer service. I'd previously had exposure to dependency injection earlier on the same project but hadn’t exactly grokked the concept fully and so with a few pointers in the right direction, I set about refactoring the code I’d written using dependency injection and Drupal services. 
Drupal Developer

Refactoring Drupal batch API callbacks to increase testability

Drupal's Batch API is great, it allows you to easily perform long running processes with feedback to the user.

But during Drupal 8's development processes it was one of the remaining systems that didn't get the full object oriented, service-based architecture.

Much of the batch API is largely unchanged from Drupal 7.

But that doesn't mean you can't write unit-testable callbacks.

Let's get started.

Pagination