Drupal Planet

Creating a Colour-picker field for Drupal

Demo/tutorial on how to create a color-picker field for a Drupal website (since color module is now deprecated).

The source code for this Localgov Microsites Colour Picker Fields module is available on GitHub.

TL;DR

  1. Create a template suggestion for the input field for the fields you want to use a colour picker with.
  2. Add 2 inputs to that template - text input and color input.
  3. Add some JavaScript to say "if either of these inputs are changed, update the other one to match". 

 

Here's an abridged version of the colour picker on CodePen.

 

See the Pen Colour Picker Input by Mark Conroy (@markconroy) on CodePen.

Join the "Something nice ..." newsletter

The full title is "Something nice, something quirky, something else".

I send an email once a week with something nice, something quirky, and something else that I think is interesting (all with a web development theme, of course).

Braindump: Choosing an e-commerce solution for Drupal

Here's a braindump to a question I answered on Slack today about choosing an e-commerce solution for Drupal.

In terms of a Drupal-native solution, there really isn’t any other option than Drupal Commerce.

You could use another platform like Shopify and use the Drupal Shopify module to import your products to Drupal for display. It looks like a decent approach but the module is only in an alpha state and hasn’t had a release in almost 2 years.

A headless platform like Big Commerce is also worth looking at, but the Big Commerce module only has 2 sites using it (in the whole world), and is itself built on top of the Drupal Commerce module.

In short, it looks like all roads lead to Drupal Commerce. Well done and thanks very much to the Centarro team for all their hard work on it.

Join the "Something nice ..." newsletter

The full title is "Something nice, something quirky, something else".

I send an email once a week with something nice, something quirky, and something else that I think is interesting (all with a web development theme, of course).

What is the schema.org Blueprints module?

Schema.org Blueprints Module video screenshot

I took the schema.org blueprints module for a spin in a "box-opening" video. I was amazed!

How easy is it to use? Well, it took me a few minutes to figure a few things out, but it's as simple as:

  1. Choose the content type you want
  2. Accept the default fields
  3. Choose if you want to add more fields types by just saying "yes" or "no" and then they get created automatically for you
  4. Enjoy a website with content created to meet schema.org standards and receive thanks from your SEO folks.

Go try out the Schema.org Blueprints module for yourself. Hat tip to Jacob Rockowitz for creating it.

Join the "Something nice ..." newsletter

The full title is "Something nice, something quirky, something else".

I send an email once a week with something nice, something quirky, and something else that I think is interesting (all with a web development theme, of course).

Sneak Peak: Proof-of-Concept of Customisable Footer for a LocalGov Drupal Microsite

LocalGov Drupal Customisable Microsite Footer, with colour scheme based on Essex County Council colours

Here's a short video giving a proof-of-concept for how to create a customisable footer for a microsite based on LocalGov Drupal and Group Module.

Note: this is VERY MUCH a proof-of-concept. What you see here may or may not end up in the final product.

Join the "Something nice ..." newsletter

The full title is "Something nice, something quirky, something else".

I send an email once a week with something nice, something quirky, and something else that I think is interesting (all with a web development theme, of course).

LocalGov Drupal on the Talking Drupal Podcast

Talking Drupal Screenshot - talking about LocalGov Drupal

I had great fun on the Talking Drupal podcast, where myself, Will, and Finn shared thoughts and experiences of the LGD distribution that we've been working on.

Myself, Will, and Finn were asked on to the Talking Drupal show recently to talk about building a distribution for local councils in the UK and Ireland.

Join the "Something nice ..." newsletter

The full title is "Something nice, something quirky, something else".

I send an email once a week with something nice, something quirky, and something else that I think is interesting (all with a web development theme, of course).

Create a Decoupled Council News Site with LocalGov Drupal and Gatsby

Screenshot of decoupled news section from localgov drupal website

Simple PoC to decoupled the news section of a LocalGov Drupal website using Gatsby.

Join the "Something nice ..." newsletter

The full title is "Something nice, something quirky, something else".

I send an email once a week with something nice, something quirky, and something else that I think is interesting (all with a web development theme, of course).

Create a Sub-theme for a LocalGov Drupal Website

Add sensibile defaults to a Drupal theme - localgov_drupal

We've put together a pretty cool base theme for the LocalGov Drupal distribution. Then we created a script for sub-theming. Everything is simple.

The long answer:

  1. cd to /web/themes/contrib/localgov_base
  2. run bash scripts/create_subtheme.sh
  3. done

The details are available in this short video:

I've started streaming some of my work, especially if it's contributions to open source, on twitch if you'd like to follow along/subscribe. As it turns out, Twitch deletes your videos after 14 days, so I have also been uploading them to YouTube. Feel free to subscribe.

Join the "Something nice ..." newsletter

The full title is "Something nice, something quirky, something else".

I send an email once a week with something nice, something quirky, and something else that I think is interesting (all with a web development theme, of course).

Create a Theme Settings Page for a Drupal Theme

Drupal - Create Theme Settings Page

Theme settings are simple and powerful, here's me figuring out how to create one.

Creating theme settings have so many uses. For example, you might have a sub-theme that wants to set a theme setting for the main/accent colour, and then use CSS variables to pull that into your theme - simple. Or, in my case, I want to create a base theme that is styled with CSS and JS, but allow sub-themes to switch off those libraries and just use the HTML from our templates.

Here's how:

 

I've started streaming some of my work, especially if it's contributions to open source, on twitch if you'd like to follow along/subscribe. As it turns out, Twitch deletes your videos after 14 days, so I have also been uploading them to YouTube. Feel free to subscribe.

Join the "Something nice ..." newsletter

The full title is "Something nice, something quirky, something else".

I send an email once a week with something nice, something quirky, and something else that I think is interesting (all with a web development theme, of course).

Supporting IE11 while still using Modern CSS

Supporing IE11 in LocalGov Drupal

Drupal currently supports IE11, and will do until Drupal 10 in about a year's time. Here's my proposal for how to support IE11 in a distribution without holding back from modern CSS.

Drupal will support IE11 until about this time next year. We have been seeing many clients say to us that they are happy to drop support for IE11 if it means they can have a better website. However, some organisations (government, etc) still use IE11 internally as their main browser, so those users need a website that works and is a pleasure to use. However, often the only users of these websites in IE11 are internal users - editors updating content - and not "visitors" to the website who are mostly using mobile browsers on their phones or modern browsers like Firefox, Edge, and Chrome on their computers.

Within LocalGov Drupal, we aim to support IE11 as long as Drupal does. However, I don't want us in a position this time next year needing/wishing to rewrite our frontend in modern CSS after we drop IE11 support. Here's my proposal to give IE11 users a really good experience via a default theme (like Wordpress does for mobile sites hosted on Wordpress.com) but uses progressive enhancement to supplement how the site works for visitors using modern browsers.

If we take the approach in this video, it means that all CSS properties are variables (fonts, line-heights, spacing, colours, etc) and then any council can use our base theme but brand it to their own brand guidelines simply using a variables.css file to override the base CSS variables. Since variables are calculated at run time, we don't need to recompile the theme to each time we make a simple change. Why is this so great/sustainable/scalable? It means sub-themes are very small, but also means we can create theme settings so editors can set some of these variables themselves (e.g. setting background colour via the CMS for Christmas, or when a notable person has passed away) all without needing to contact developers.

But won't the site look different in IE11 to other browsers? If you site uses the base theme, it will look the same in all browsers. If you site uses the base theme but extends it, then it will look like the base theme in IE11 but your branded theme in other browsers. Remember, sites already look different in different browsers - everything stacks in one column on phone browsers buy is side-by-side on desktop browsers, etc. Different does not mean bad.

 

I've started streaming some of my work, especially if it's contributions to open source, on twitch if you'd like to follow along/subscribe. As it turns out, Twitch deletes your videos after 14 days, so I have also been uploading them to YouTube. Feel free to subscribe.

Join the "Something nice ..." newsletter

The full title is "Something nice, something quirky, something else".

I send an email once a week with something nice, something quirky, and something else that I think is interesting (all with a web development theme, of course).

LocalGov Drupal: Creating Sensible Defaults in your Theme

Add sensibile defaults to a Drupal theme - localgov_drupal

We often end up with a lot of templates when theming, but we should also remember to create "sensible defaults", so before you start theming specifically your site doesn't look broken.

Writing sensible defaults means that the dev we might perform or the CSS we might write for a new feature/component is additive, and you do not need to reset libraries and/or write code to overwrite other code. Here's an outline of creating sensible defaults for our region template within the new localgov_base theme - region.html.twig.

I've started streaming some of my work, especially if it's contributions to open source, on twitch if you'd like to follow along/subscribe. As it turns out, Twitch deletes your videos after 14 days, so I have also been uploading them to YouTube. Feel free to subscribe.

Join the "Something nice ..." newsletter

The full title is "Something nice, something quirky, something else".

I send an email once a week with something nice, something quirky, and something else that I think is interesting (all with a web development theme, of course).