You are here

Drupal 8

Create a View of content from Groups a user is member of - Drupal 8

The Group module is a powerful one I turn to often when a site has a requirement for groups of users who should have specific permissions, access to edit or view specific content, etc.

A common requirement is to show a list of content belonging to the Group(s) a user is member of, using Views. That isn't as straightforward as it seems. I recently had to do this and struggled a bit, so thought this solution might be useful for someone else.

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: