You are here


Posted Oct 9, 2019

I've worked on several sites recently where the site search form is hidden by default and displayed by activating a button. This pattern caused me a bit of confusion about where to put the role="search" attribute, which is important for accessibility. According to the W3C specification the search role is: A landmark region that contains a collection of items and objects that, as a whole, combine to create a search facility. Assistive technology users can navigate by page landmarks if they are...

Tags: accessibility, search, landmarks, aria

read more

Posted Oct 3, 2019

I'm working on a website which has a list of products, displayed in a View. Each product has an "provider" who produces it, associated with the product content type by an entity reference field to a Provider content type and displayed in the view. The client wanted contact information for the providers to show up in the list as well. It would have been a bit bulky and repetitive to have the contact information displaying in each row of the View. Therefore, I wanted to display a block above the...

Tags: Drupal 8, views, how to

read more

Posted Oct 2, 2019

Hatticus is a fun, cabled hat with a pointed top and pom-pom knit in super-bulky yarn. Due to the giant yarn and needles, it's a super-fast knit. This pattern was on Ravelry, but as I'm no longer on Ravelry I thought I'd upload it here for anyone who might go looking for it. Feel free to leave a comment here or send me a message with any questions or corrections. Happy knitting! Hatticus: Free Super Bulky Cabled Knit Hat Pattern


read more

Posted Sep 23, 2019

Recently, I was creating an event registration Webform. I created a custom composite field with the fields needed for each registrant: first name, last name, and a set of three radio options for their organization status: member, non-member, membership fee included in event registration. Each status has a different registration fee. I then wanted to create a computed Twig field that would calculate the total registration fee by getting the data from the chosen radio option for each attendee and...

Tags: Drupal 8, Webform, twig, calculated field

read more

Posted Jul 11, 2019

I've been maintaining or building websites since September of 1999. At the time of this writing, that's almost 20 years. One of my main focuses as a web developer is usability/accessibility—making the sites I build intuitive, easy to understand and operate, and accessible to all users, including those with disabilities, as much as possible. Those things are super important to me. But why? Part of it, I suppose, is altruism. But part is also this: the fact that I'm a web developer doesn't...

Tags: thoughts, accessibility, usability, design

read more

Posted Jun 7, 2019

A super common pattern for websites is a list of content with one (or more) featured items (say a news article), then some more items, excluding the featured one. The featured item might display at the top and/or larger than the rest. Here's an example of how to achieve that in Drupal 8 using Views. Note that there are many ways of flagging featured content. In this case, we want to display the items on the front page. We have a Homepage content type with an entity reference field called "...

Tags: Drupal 8, views, how to, featured

read more

Posted May 21, 2019

I've been working on a site with events, and tearing my hair out over how to print formatted dates with the correct timezone value in Twig templates, specifically node.html.twig and views-view-fields.html.twig. The issue was first, getting the formatted date to display in the template; and secondly, when I managed to get it displaying, it was not in the correct timezone; it was off by several hours. The accepted answer to this StackExchange question was the key to cracking the problem....

Tags: Drupal 8, twig, date, fields, theming

read more

Posted May 17, 2019

I'm working on a website which has icons on file upload links, like so: This is nice for people who can see the icons, but what about those who can't? Accessibility means giving all users an equivalent experience, regardless of how they're accessing the site. In this case, we want to add a visually hidden span at the end of file links with the filetype, e.g. "(PDF)". This will let screen reader users know that the link will open a file, so they're not surprised. We want it to be visually...

Tags: Drupal 8, accessibility, theming, twig

read more

Posted Apr 23, 2019

By default, the label for the search form text input in Drupal 8 is set to invisible, that is, it's present but hidden by applying the "visually-hidden" class so users of assistive technology can still read it. But what if you want to display it visually? That's not so easy. There's no way to do it through configuration, and little to no information about how to do it with code. I muddled around and finally found where the visibility was being set, in SearchBlockForm.php in the core Search...

Tags: Drupal 8, search block form, label visibility, forms, theming

read more

Posted Apr 17, 2019

Data attributes on HTML elements can be very handy for targeting certain elements with CSS and/or Javascript. Let's say, for example, we have a site with a menu whose links have a different background colour depending on what category they belong to, cats or dogs.The HTML might look like this: <ul class="menu">  <li class="menu-item">    <a href="#">Cats rule</a>  </li>  <li class="menu-item"...

Tags: Drupal 8, twig, CSS, data attributes, html

read more