Drupal articles

Allow editors to use HTML attributes by default

26th Oct 2022

Drupal provides an excellent sanitisation system to filter the HTML content that editors might create. Think of it like a series of traffic cops that filter different vehicles into different lanes. Some content is allowed through to its destination, some has to be transformed along the way, and some is simply blocked from displaying. Administrators can use the 'Limit allowed HTML tags and correct faulty HTML' option to configure which HTML elements and attributes they can use. This helps protect a site against nefarious HTML - whether it might be malicious or just ugly. Under Drupal 9, editors can't use...

Read more

PhpStorm coding tip for Drupal services

29th Jun 2022

Here's a super simple tip to help you work with services for Drupal in PhpStorm (our favourite IDE). First, ensure you have enabled the Drupal Symfony Bridge and Symfony Support plugins; they're brilliant for auto-complete suggestions, and navigating around services, controllers, annotations and twig templates! I find it so helpful to be able to cmd+click (or ctrl+click) on a service name, whether in a YAML definition, or PHP code, and jump straight to the service class. But I'd noticed that PhpStorm often didn't recognise the method used after my code referred to a service like this:

\Drupal::service('my_service')
  ->something($id);
Read more

Core web vitals - First input delay

Part of the series
Core web vitals
19th Oct 2021

If your website gets a lot of traffic from search engines, and Google in particular, then you need to care about all the things that Google wants you to care about, including 'First input delay'.

If you don't pay attention to this metric then you may find Google lowering your site in their rankings and thus you get less and less traffic to your site. Usually, we aim for more traffic, not less :)

First input delay

There are many great articles explaining what First Input Delay is, so go read them if you need to, and then come...

Read more

Get Hook-ed on Object-Oriented Programming

15th Sep 2021

Does writing hooks make you sad because the code is too procedural? Are you keen to use the object-oriented programming approach that Drupal and its service container enable, wherever you possibly can? Read on if you answered yes to any of those questions.

Read more

Migrating Drupal 7 Files into Drupal 8 / 9 Media entities

27th Jul 2021

This article assumes a basic knowledge of the building of custom modules, the Drupal 8 / 9 Migration system, and the processes behind creating customised migrations from a previous version of Drupal.

One of the more common components of any migration from a previous version of Drupal is the need to migrate files. In Drupal 7 there was a core ‘File’ entity type and on pretty much all of our clients' sites we would also have the contributed module File Entity enabled. This extended the core file functionality and gave the ability to add fields to the file entity, have...

Read more

Custom node routes

20th Jul 2021

Sometimes it can be handy to have extra pages for a node (or any entity). For example:

  • To show different sets of information on separate pages for a single product, page, or thing.
  • So you can set different access requirements on each page for a node.
  • You want to block access to the ordinary route (e.g. node/123 and its aliased equivalent) for some reason, but you still want some other page to represent that node.

I've found a few people with that need on Drupal slack before, so I thought I'd write a guide because it's surprisingly...

Read more

Entity Extra Field module: display blocks & views amongst fields

14th Jun 2021

I'm a fan of configuring things for display through Drupal's admin UI. It gives site builders confidence and power. What if you want to place blocks or views listings in amongst fields on pages of content? For example, to display:

  • A listing (view) of related content, such as accessories for a product
  • A standard contact block, advert, or some other calls to action in the middle of the content, exactly where the user is best 'caught' in their journey, rather than having to stick those in sidebars or after all the content fields.
  • Some specific value(s) pulled from fields on some indirectly related entity, through a token, such as details from a taxonomy term representing the 'section' that a page is in.
  • Consistent relevant links on user profiles to take people to common destinations

This is where the Entity Extra Field module (entity_extra_field) comes in. It supports embedding blocks, views or values to be replaced via tokens. So a site builder can set these up to be managed just like ordinary fields on the page (whether it's a node, term, paragraph, or any other type of content).

Read more

Context-aware blocks

9th Jun 2021

Defining your own Drupal block plugins in custom code is really powerful, but sometimes you can feel limited by what those blocks have access to. Your block class is like a blank canvas that you know you'll be pulling data into, but how should you get that data from the surrounding page? Often you have to resort to fetching the entity for the current page out of its route parameters (e.g. on a node page), in order to get the values out of its fields that you want to display. Plugins can actually have a context passed to them directly...

Read more

ComputerMinds are diversifying

1st Apr 2021

The last year has highlighted to us all how important it is for the global community to come together and solve problems. We rate ourselves highly at ComputerMinds, and figure it's time to share and stretch our abilities to the full. So I'm here on this special day to announce that we are branching out beyond just resolving bugs on websites, to fixing any kind of bugs in any problem space. There's so much market potential, we're really quite excited at the possibilities for bringing innovative solutions to the world!

Medical bugs

The ugliest bug of them all, COVID-19, has...

Read more

21 for 21 - The move more challenge

Jenny Smailes
Jenny Smailes
16th Mar 2021

I think the majority of us would say that we are not moving as much as we were pre-lockdown and pandemic. If you are then well done!  A lot of us have lost a commute and access to our usual exercise regime and are pretty stationary at home working and/or with our kids.  Of course, we could always go on ANOTHER muddy walk. However, I don't know about you but I'm pretty fed up of taking 3 young children on muddy walks all the time - I have enough washing to do as it is!  I digress.  My point is, many of...

Read more