For me this is the biggest unanswered question hanging over my development of Drupal 8 websites: How should I add config to a Drupal 8 site? This article will provide plenty of options, but unfortunately no definitive answer.
Class Aliasing is the simple, but very useful solution to the problem of needing to use two classes (from different namespaces) with the same name.
This article will talk you through the steps to follow to write a simple PHPUnit functional (Kernel) test for Drupal 8. I have been doing a lot of work on Drupal 8 migrations for the past few months so that will be the focus of the test.
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!" With the introduction of Symfony, your new BFF is an Event Subscriber. Alter hooks still exist, but it is recommended that we all move towards Events to fall in line with Symfony. If you are interested in the comparison between alter hooks and events then I...
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! Panic not. The solution is nice and easy, the following snippet will act as a drop in replacement for drupal_is_front_page() - simply returning TRUE or FALSE. \Drupal::service('path.matcher')->isFrontPage();
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 do something more complicated than write 'Hello World' to your database 5,000 times. Let's take a look at some Drush essentials. Arguments and Options You guessed it -...
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 on the viewport / device, we now have two options: we can again rely on media queries, or we can use the srcset and...
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 tricky enough already, let's just do it some other way"? Well, it's actually surprisingly easy to write your own Drush commands, and it's totally something...
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. Workflows like that provided by Workbench Moderation give previews that work nicely, but that involves a lot of complexity with revisions and workflow. It really changes the way you (and your nodes, for...
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: My homepage, originally in French, has had an English translation added, but whilst editing in English, I had to search with the French title in order for the page to come up... with the English title! Here's how to solve this... My...