Skip to main content

Planet Drupal

Content that's out of this world ...

Planet image
The articles on this page are ComputerMinds' contribution to the Planet Drupal aggregated article feed.  Planet Drupal is intended to collate interesting and useful Drupal content from around the web.

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

Apply Drupal 9 compatibility patches with Composer

12th Jan 2021

Update! Since this article was written, a new 'lenient' composer endpoint has been created on Drupal.org to support using modules with Drupal 9 that haven't been marked as compatible with it yet. See the documentation, which boils down to adding a new common entry under 'repositories' in your composer.json, above the usual https://packages.drupal.org/8 one. The rest of this article is still useful for understanding how patching fits into composer's workflow.

The vast majority of community-contributed Drupal 8 modules now have releases that are compatible with Drupal 9, but what can you do if you need to use a module that...

Read more

Core web vitals - how to debug and improve cumulative layout shift (CLS) issues

Part of the series
Core web vitals
11th Nov 2020

TLDR : Check your cookie popup!

It seems everyone is talking about core web vitals at the moment, spurred on by Googles’ recent announcement that page experience (which includes core web vitals) will start influencing search ranking in May 2021.

We won’t go into detail on web vitals in this post - there is plenty of information already on the web, including from Google themselves on the excellent web.dev site.

Instead, this post will look specifically at cumulative layout shift - or CLS as it’s known. I like to think of this as the jerkiness measure of your site -...

Read more

Reflecting on Drupal Slack

27th Oct 2020

Over the last year or so, I've got quite engaged with Drupal slack. I've loitered in channels like #d9readiness and #config, discussed issues with members of the security team, and asked questions to module maintainers (and received answers!). But most of all, I've helped people out in the #support channel. This has been an interesting experience in many ways, so I thought I'd share my reflections. The Drupal slack workspace is intended for the community, so if you're reading this - it's probably for you too. Hopefully my thoughts might help prepare you to use it as an effective tool.

Ultimately, I've got...

Read more

Rendering fields in Drupal 9 (the right way)

Part of the series
Upgrading to Drupal 9
28th Jul 2020

Many of us at ComputerMinds have always taken pride on doing Drupally things the right way whenever possible, and then helping the community do so too. One of these things is displaying values from fields on content entities. We wrote before about how to do this in Drupal 7 and Drupal 8. It's now the turn of Drupal 9! Thankfully, this updated version is basically the same as the last one, as D9 is very similar to D8 on the surface, but with old cruft ripped out to allow it to continue improving. So the short answer to "How...

Read more