Articles · Page 8
Notes from the team.
Aegir is ten!
Ten years ago today Adrian Rossouw committed the first code for the Aegir project. ComputerMinds have been involved in Aegir for many of those years, particularly one of our senior developers: Steven Jones. We asked him some questions about it to mark the occasion.Read article →Get the entity for a route
In Drupal 7, we had menu_get_object() to get the object in code for whichever node, term, or whatever entity makes up the current page. But in Drupal 8, that has been replaced, and entities can usually be operated on in a generic way. If you know the type of entity you want,…Read article →Help Drupal help your configuration
TL;DR: Define a schema for any bespoke configuration, it's not too hard. It's needed to make it translatable, but Drupal 8 will also validate your config against it so it's still handy on non-translatable sites. As a schema ensures your configuration is valid, your code, or…Read article →Drupal as a Server - Introduction
This post is the first in a series about getting Drupal to run as a persistent server, responding to requests without bootstrapping each and every time.Read article →Show elements with form #states when values do not match
I've previously written about dynamic forms in Drupal, using #states to show or hide input boxes depending on other inputs. Since then, Drupal 7 and 8 have both got the ability to combine conditions with OR and XOR operators. This makes it possible to apply changes when a form…Read article →Loading config programmatically
In Drupal 8, there are many ways to interact with configuration from PHP. Most will allow you to write the config values, but some are read-only. Some will include 'overrides' from settings.php, or translations. There are many layers of abstraction, that each have different…Read article →Commands I use when creating a patch for drupal.org
Over the past couple of years I have become more active in issues on drupal.org, in which time I have honed a selection of commands that I regularly use in the creation and application of patches. Here is a run-down of my most useful commands.Read article →Replacing a vocabulary listing
In a recent Drupal 8 project, one of the site's vocabularies had several thousand terms in it (representing airports), which caused its admin listing page to run out of memory before it could render. I wanted to solve this without affecting any other vocabularies on the site,…Read article →Drupal with Composer on Apache on Bash on Windows 10!
I've recently been playing around on Windows 10's new Bash on Ubuntu feature, which provides a native bash linux shell for Windows. I thought I'd try and get a Drupal 8 site running, via composer, served from Apache, without any need for a virtual machine in Windows. Kristian…Read article →Drupal 8 Views: How to set as admin path
In Drupal 8 admin paths are now defined as part of route definitions so are no longer defined in hook_admin_paths(). In many cases, uniting routing with admin path definition makes things easier - simply add _admin_route: TRUE in a .routing.yml file, but not when it comes to…Read article →Drupal 8 Views: How to formulate the route name
This article will explain how to formulate the route name for a view because there are very few sources for the information online.Read article →Question: When should I define a service?
We've been getting stuck into Drupal 8 development and have been grappling with the concepts of services, dependency injection and containers.Read article →Dependency Injection - how to access services in controllers
If you are trying to get to grips with Dependency Injection in Drupal 8 then here is a walk-through of how I applied it in one of my Drupal 8 test projects.Read article →Drupal 8 Config Management - how should I add config to a D8 site?
For me this is the biggest unanswered question hanging over my development of Drupal 8 websites:Read article →Drupal 8 Namespaces - class aliasing
Class Aliasing is the simple, but very useful solution to the problem of needing two classes (from different namespaces) with the same name.Read article →How to write a PHPUnit functional test for Drupal 8
This article will talk you through the steps to follow to write a simple PHPUnit functional (Kernel) test for Drupal 8.Read article →Drupal 8 Event Subscribers - the successor to alter hooks
In Drupal 7 if you wanted to tweak the functionality of an existing function then an alter hook was your best friend, but in Drupal 8 it's "all change!"Read article →Checking if the current page is the homepage in Drupal 8 - not using drupal_is_front_page
We will keep this one short and sweet. There is quite a bit of documentation pointing to the fact that drupal_is_front_page() still exists in Drupal 8 ... it doesn't!Read article →How to write a (more useful) Drush command
Welcome to part two of our miniseries on Drush commands! Do check out part one if you haven't already. There you'll see what we've been up to with our pretend module, my_awesome_module. If you're writing a custom Drush command, it's pretty much guaranteed that you're needing to…Read article →Responsive images with srcset and sizes
Responsive design is now the norm when it comes to developing modern websites, and most of us will be all too familiar with how we use media queries to get our sites looking different on a whole range of different devices. When it comes to getting our images to resize depending…Read article →How to write your own Drush command
Occasionally there's something you need to achieve, which would be really easy if only you could have it performed via Drush - some script that could be run on the server during an update or migration process, perhaps. But it all looks a bit too scary, right? "The task is…Read article →Making an accurate, responsive node preview for Drupal 7
It's a well known fact that a large proportion of sites turn off the node preview button. It just doesn't work well. Your unsaved changes don't show and the admin theme is used in place of your site theme - not helpful.Read article →Language lessons: How can I fix my autocomplete box?
Languages make everything so complicated! I just discovered the autocomplete bit on my reference fields wasn't working - until I tried searching by another language, and then the results gave me a surprise:Read article →Language Hierarchy: More power and flexibility without extra effort
Several of our recent projects have involved setting up languages that feel like 'child' languages of other languages, for a variety of reasons. Sometimes it's for marketing, so that content can be overridden for markets using a specific currency, other times it's to target a…Read article →Let's talk
Got a Drupal problem you'd like a second opinion on?
You'll talk to a developer, not a salesperson.