You are here

Drupal 8

Show complementary information in a View based on exposed filter choice - Drupal 8

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.

Calculate a value from options field in Webform custom composite element with Twig - Drupal 8

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 adding it up. This proved surprisingly tricky.

How to create a View with a featured item and a list that excludes the featured item, Drupal 8

A common pattern for websites is a list of content, for example news, with one (or more) featured items, followed by a list of a few more items, excluding the featured one(s). This seems like it should be simple to do, but it's not as straightforward as it seems.

How to make search block form label visible - Drupal 8

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 module. In there we find:

Truncated expanding text field with "show more" link in Drupal 8 & Twig

I've been working on a website with the requirement to truncate certain text fields—display the first several words of the text, with a "show more" link which on click, expands the rest of the text.

As I was under a very tight deadline, I found and implemented a jQuery plugin that did what I needed. Quick and easy.