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.

Article
Posted on 18th December 2018
Takes about 3 mins to read
There's nothing like Drupal's default spinning blue AJAX animation to make you notice that a site's design hasn't been fully customised. The code from my previous article showing how to fetch a link over AJAX to open in a Foundation reveal popup would suffer from this without some further customisation. After clicking the 'Enquire' button, a loading icon of some kind is needed whilst the linked content is fetched. By default, Drupal just sticks that blue 'throbber' next to the link, but that looks totally out of place. Our client's site uses a loading graphic that feels much more appropriate in style and placement, but my point is that you can set up your own bespoke version. Since it's Christmas, let's add some festive fun!
Article
Posted on 12th December 2018
Takes about 8 mins to read

After reading this from Ars Technica, which describes how a developer offered to 'help' the maintainer of an NPM module - and then slowly introduced malicious code to it - I can't help but wonder if the Drupal community is vulnerable to the exact same issue. Let's discuss! ###Please, don't touch my package NPM modules have been hacked at before, and it's not pretty when it happens. Because of the way we use packages, it's...

Article
Posted on 4th December 2018
Takes about 7 mins to read

Let me take you on a journey. We'll pass by Drupal content renderer services, AJAX commands, javascript libraries and a popular front-end framework. If you've only heard of one or two of those things, come lean on the experience I took diving deep into Drupal. I'm pleased with where my adventure took me to, and maybe what I learned will be useful to you too. Here's the end result: a contact form, launched from a...

Article
Posted on 9th November 2018
Takes about 1 min to read

I'll keep this short and sweet, but we thought this would be a useful tip to share with the world as a potential security issue with the combined use of File::getFileUri() and FileSystem::realpath(). Consider the following code excerpt : $file = File::load($some_file_uri); if ($file) { $uri = $file->getFileUri(); $file_realpath = \Drupal::service('file_system')->realpath($uri); } Seems pretty harmless right? Load up the file from $some_file_uri , If we have a valid file then get the URI and then...

Published in: #Drupal Planet #Drupal 8 #security
Article
Posted on 18th October 2018
Takes about 1 min to read

Update: this article's suggested method has serious shortcomings, use other methods when you can! For example, run the following with drush to just upgrade drupal core code (leaving database updates to be run separately): drush pm-updatecode drupal --check-updatedb=0 If you've got a Drupal site, which you need to update quickly (for example, to address last night's security advisory!), here's a tip. Run this from the command line: curl 'https://github.com/drupal/drupal/compare/7.59..7.60.patch' | patch -p1 This assumes your...

Article
Posted on 14th August 2018
Takes about 1 min to read

A client noticed the dates on their news articles were not being translated into the correct language. The name of the month would always appear in English, even though all the month names had themselves been translated and showed correctly elsewhere. The problem turned out to be down to the twig filter being used in the template to format the date. This is what we did have: ```twig {% set newsDate = node.getCreatedTime|date('j F Y')...

Article
Posted on 9th August 2018
Takes about 3 mins to read

The Problem I imagine many of us have been there: there’s some CSS class in your markup, and you need to do something with it. Maybe you want to remove it, change it, or perhaps alter its style declarations. “Easy peasy,” you think, “I’m a developer. I got this.” And so you should. Next, if you’re anything like me, your first instinct is to fire up your search tool of choice and search your...

Article
Posted on 26th June 2018
Takes about 2 mins to read

Let's say you've built a custom form for your Drupal 8 site. It contains various elements for input (name, email address, a message, that kind of thing), and you want to send the submitted values in an email to someone (perhaps a site admin). That's a pretty common thing to need to do. This could be done with Drupal's core contact forms, webforms, or similar -- but there are cases when a bespoke form is...

Published in: #Drupal Planet #email #Forms #token #Drupal 8
Article
Posted on 11th June 2018
Takes about 3 mins to read
This article is part of the series
Rebranding ComputerMinds

I volunteered to carry out the migration for the new ComputerMinds site as migration was one of the very few areas of Drupal that I hadn’t delved into thus far. With Drupal 8 becoming more and more popular, now was a great opportunity to learn the migration ropes. Luckily, Drupal 8’s migration has greatly improved since Drupal 7 so my life was made somewhat a little “easier”! This article will be aimed at some of...

Published in: #Drupal 8 #Migrate #code #yaml #Drupal Planet
Article
Posted on 1st June 2018
Takes about 8 mins to read
This article is part of the series
Rebranding ComputerMinds

Let's have a quick look through our development process on this project and pick out some of the more interesting bits. As briefly mentioned in the last article we are using a composer set up and all code is version controlled using git on github. All pretty standard stuff. Frontend In the previous article I briefly discussed how we set up Pattern Lab. Before getting stuck in to the components that would make up the...