Drupal Planet

Big Blue Door are going to sponsor me to work on LocalGov Drupal

Beautifully crafted digital products and experiences that matter.

No sooner had I written a blog post suggesting people could sponsor my work on LocalGov Drupal than Big Blue Door had answered the call.

I mentioned in my last blog post that if agencies and organisations wanted to contribute more to open source but can't because they are busy with client work, then why not sponsor some one else to contribute for them.

If the person contributing is a seasoned contributor and ready to work on a project that you are invested in, it makes perfect sense. It also means that person can hit the ground running and start making an impact straight away. With this being the case, Big Blue Door got in contact with me and instead of offering me sponsorship of one day per week (which is what I was asking for), they offered two days per week.

This is great news and a quadruple win-win situation for:

  1. LocalGov Drupal - we'll get to fix lots of issues in the backlog and perhaps work on some new ones
  2. UK and Irish Councils - an even better LGD site for you, without you needing to pay anything
  3. Big Blue Door - they get to have high quality contributions to the LocalGov Drupal project, showing themselves to be very conscientious community members
  4. Me - I get paid for doing something I love

Please join me in thanking Big Blue Door for their very generous support of my open source development.

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).

Does your agency want to contribute more to Drupal?

Mark Conroy Speaking at DrupalCon Amsterdam 2019

Lots of agencies want to contribute more to Drupal, but don't have the time due to client work. Let's fix that.

Having spoken to a lot of Drupal agencies recently, a common theme keeps emerging: we want to contribute more to open source/Drupal but we don't have the time due to client work, or we don't have people who are used to contributing.

That seems like a problem worth solving. It will mean more contributions to Drupal, faster iterations of Drupal features (let's get Starshot launched asap), and ultimately more Drupal credits for your agency.

How do we solve it? Simple, you find someone that is available for work currently, and is also well-used to contributing to Drupal, and perhaps is also a Drupal core maintainer, and you fund them. If you are wondering who, well ... me, for example. 

What will you get for funding a Drupal core developer?

  • A mention on each comment on issues I am working on on Drupal.org (something like "Thanks to <agency name> for sponsoring my time to work on this issue").
  • A credit for any issues I am working on (add me to your organisation on Drupal.org and I'll tag it as the organisation paying for the work).
  • A mention at the top of any blog posts I write to explain an issue I am working on.
  • A mention in any videos I create as a demo about any issue I am working on.
  • One day per week of Drupal core contributions (or as much as you want to fund).

What initiatives do I want to work on?

How do we get started?

This is the easy bit.

You send an email to mark@mark.ie and I'll get back to you asap to have a chat about how the engagement will work. Then we start working on it, you start getting Drupal.org credits, and Drupal gets better. 

Everyone's a winner!

 

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).

Using the LocalGov Drupal Subsites Extras module

LocalGov Drupal Subsites Extras module

Create subsites with a different look and feel to the rest of your LocalGov Drupal website.

This is what open source collaboration looks like. Thanks to:

  • Chicken - Justine and Rupert for developing this module
  • Will Callaghan for requesting it in a generic manner so all councils can benefit from it
  • Essex County Council for funding
  • Hammersmith and Fulham Council for managing it and creating the initial prototype
  • Annertech (me!) for testing and suggestions

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).

Show the last author of a node in the Drupal content list

Show "last edited by" on the Drupal admin/content view

Instead of showing the original author of a node, show the last person to edit it.

Drupal's content listing at admin/content shows us the creator of a node, but does not allow us to add a field to show us the last person who edited the node. 

I did some Googling for it, and it turns out the ability during the latter stages of Drupal 8 development, but I wasn't aware of it. I'd like to see this added to the default admin/content view so we wouldn't have to figure it out.

So ... here's how to do it:

  1. Create a relationship to the The user ID of the author of the current revision.
  2. Then use that relationship in the fields you want to show.

Here it is in video format:

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).

Drupal Content Access by Path module

Content Access by Path

Ever needed to give a Drupal content editor access to edit site sections instead of the whole site? Introducing the Content Access by Path module.

Here's a module I created, funded by Essex County Council and based on a spec developed by Will Callaghan, that allows you to create taxonomy terms, then set paths (via a text field) on those taxonomy terms, and then attach those taxonomy terms to users. 

Now, when a user has a taxonomy term attached to them, they can only edit content that is within the range of that path.

I'm surprised this module didn't already exist.

It's available on Drupal.org at the Content Access by Path namespace.

Here it is in action:

 

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).

How to use once() in Drupal

Once is a Drupal library - available on npm - that ensures your JavaScript only runs once when working on any item.

I put a snippet on a Slack channel recently suggesting that someone should use once() to make sure their code didn't run multiple times. And then I gave them this snippet to show how to use it:

const editFrequencys = once('allEditFrequencies', '.edit-frequency', context);

editFrequencys.forEach(editFrequency => {
  editFrequency.on('change', function() {
    $.ajax({
      method: "POST",
      url: "/frequency-select",
      data: { name: "John", location: "Boston" },
      dataType: "json"
    })
      .done(function( data ) {
        console.log("It's done!");
        console.log(data);
      });
  });
});

Job well done, Mark, you might say. Yes, but then the author asked me:

What are the different arguments about in the first line?
I've seen this code in searching for an answer, but nothing ever explains what/why the arguments for the "once" are for.

And that reminded me of a younger me. Me about 6 months ago, when I first tried to use once(). So here is the explanation I gave them:

const editFrequencys creates a variable for what you want to work on. It’s a plural, because once always returns an array. You could do something like const [editFrequency] to just return one item if you were sure there was only ever going to be one of the thing you are looking for on the page. But I find it better to return the array just in case in the future a second instance of the thing is on the page.

once() is the function that will ensure the code that is acting on your “thing” will only act once.

'allEditFrequencies' is a name that we assign to this item. You can assign anything to it basically, such as 'justSomeStuff'. This is then attached to the property in your DOM via a data attribute, such as data-once="allEditFrequencies" so JS knows which once function this item belongs to.

context is just the method that is going to be used to find your array. You could use document here, but if the page gets updated via ajax, then document will not be updated, so in Drupal terms, context is probably better.

If I got something wrong there, or there's something I should update, let me know.

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).

Adding Advanced Layouts to a LocalGov Drupal Website

Adding Advanced Layouts to a LocalGov Drupal Website

There's a (hidden away) module in LocalGov Drupal that's a game-changer for layout possibilities.

The LocalGov Drupal Layouts module was created as part of the LGD Microsites platform, but contributed back to the core LGD project. However, it is not turned on by default (todo: propose it gets turned on by default), so I think a lot of people are not aware of it.

Here's a short demo of how to enable it and use it. Then you can extend it to add as many layout options as you want to your LGD layouts.

If you'd like to chat about how you might use this, connect with me on the LGD slack or via the Annertech contact form.

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).

Using Drupal's Webform Module to Create a Decision Tree

Using Drupal's Webform Module to Create a Decision Tree

Ever needed to create a "decision tree" or "Smart Answers" feature and didn't know where to start? It's pretty easy if you use Drupal's webform module and add conditional handlers for the confirmation settings (all through a few clicks in the webform UI).

Creating a decision tree is quite easy using the Drupal Webform UI. Here's the outline:

  1. Create the form
  2. Add all the questions that you want
  3. Use the "Conditions" tab in each question to set the conditions for what question shows where
  4. On the settings page for the form, under "Email/Handlers" add a handler for the confirmation page settings for each potential response in the decision tree.

Here's a video outlining the steps:

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).

Setting up Access Control with Drupal's Workbench Access Module

LocalGov Drupal Content Access Control

This is a short video for how to use the LocalGov Content Access Control Module, based on Drupal's Workbench Access module.

Many (if not all) councils have been asking for a way to do "access control", whereby only certain editors can edit certain parts of the website. I put together the LocalGov Drupal Content Access Control module so we'd have a defined way of doing this and all councils can have a similar approach. 

Here's a short video explaining how it works (which might help people outside of councils who also need to set this up). In short:

  1. Create a taxonomy called "Access Control".
  2. Add terms to this.
  3. Use this taxonomy in a "Workbench Access" scheme.
  4. Add editors and/or roles to the site sections.
  5. Add a field to content types that references the "Access Control" vocabulary.
  6. Enjoy!

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).

Proposed new Theme Settings for LocalGov Drupal unpublished Content

New theme Settings for Unpublished Content in a LocalGov Drupal website.

We added Drupal's default pink background to LocalGov Drupal's unpublished pages recently. It didn't go down as well as we might have hoped!

Drupal by default sets a pink background on unpublished nodes. We added this as a feature to LocalGov Drupal recently to distinguish between published and unpublished content. 

Editors were not very impressed with this because - especially on new websites - there's lots of whole sections that are unpublished. And when trying to preview a full section to stakeholders and nearly every page has a pink background, including all the items in entity reference fields and other listings, the site starts to not look like what was designed.

To get around this, I've proposed 2 site settings that can be enabled via the theme settings page if your theme uses LocalGov Base as its base theme.

  1. Turn off the pink backgrounds (handy if you just want to turn them off temporarily while demoing your content and then back on again once the demo is over)
  2. Add the word "Draft" to the title of any node that is unpublished (handy if the pink background is turned off more permanently).

Here's a short video to show it all working:

The code for this can been seen in this pull request on GitHub.

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).