Specbee: Creating custom design systems with Tailwind CSS and implementing it in Drupal

Planet Drupal - Tue, 2022/06/07 - 3:49pm
Creating custom design systems with Tailwind CSS and implementing it in Drupal Pratik 07 Jun, 2022

Do you find it frustrating to style your websites sometimes because of constraining design decisions that are hard to undo? Do you want a CSS framework where you can build bespoke designs easily with less-to-no coding? Let us introduce you to Tailwind CSS - a utility-first CSS framework that can revolutionize the way you style your website and applications with a unique approach. Read to find out more about Tailwind CSS and also learn how to implement it in your next Drupal project.

What is Tailwind CSS

Tailwind CSS is a CSS framework used for styling websites and applications. A framework that offers an easy styling process similar to bootstrap but with many useful features. It is a utility class based framework in that it has tons of pre-existing classes that work according to values, prefixes, and abbreviations that are self-explaining. Which means that with Tailwind, you can create custom components without writing any custom classes or code.

Why use Tailwind

As we previously mentioned, Tailwind CSS eases the frontend work because of its extensive built-in classes that you can simply call into any HTML element. So, this means you don’t have to leave your HTML file to customize any HTML code. It provides a default theme with preset values for color palette, fonts, breakpoints, spacing and much more. This theme is also highly customizable. 

  • Powerful - Makes the styling process faster because of it’s ready-to-use classes that can be further extended
  • No-more Naming - You don’t have to rack your brain to come up with the most apt class name
  • Reusability - Save your CSS file from bulking up by using and re-using classes
  • Global Warning - Worry less about breaking the design because you don’t need to make global changes in the CSS file 
  • Responsive -  Lets you build complex responsive interfaces with its broad set of utilities and breakpoint prefixes
  • Improved Site Performance - Cleans out all the unnecessary code from your bulky CSS file. Usually ships less than 10kb of CSS.
  • Easy Maintenance - maintaining HTML is much easier than maintaining a large CSS codebase
Installing Tailwind

There are many ways you can install Tailwind CSS. We’re going to discuss installing with the help of package managers, CDN and Drupal’s contributed modules.

Method 1: Using Package Managers

1. First, install a package manager like npm or yarn to install Tailwind.

2. Execute the following commands in order: 

npm install -D tailwindcss npx tailwindcss init

3. Configure the Tailwind config file

 

4. Import the following directives in the CSS file:

@tailwind base;
@tailwind components;
@tailwind utilities;

 

5. Generate the CSS output by using command

npx tailwindcss -i ./src/.css -o ./.css --watch

6. Link output CSS file to HTML

Method 2: Installing it in Drupal using contributed modules

You can implement Tailwind CSS within Drupal using the following contributed modules:

  • Tailwind CSS Starter Kit
  • Tailwind CSS Utility

Tailwind CSS starter kit module is a starter kit or demo theme that you can use in Drupal. Simply install it using Composer or manually using Drush and enable it as your default theme. You are now ready to use all the Tailwind classes!

The Tailwind CSS Utility module adds tools for the Tailwind CSS framework. It lets you add styles to pages, sections, blocks and also integrates with Layout Builder.

Method 3: Using Tailwind CDN

To install Tailwind CSS using a CDN, add the following script to the section of your HTML:

Example:

    Document

However, I do not recommend installing it using the CDN method as it lacks some functionality. For example, you cannot customize Tailwind’s default theme or install 3rd party plugins.

How to use it?

Now that you know how to install Tailwind CSS and add it in your project, using it is a breeze. 

Simply head over to your HTML or Twig file. Add the CSS classes provided by Tailwind to any HTML element.

Now check output on the browser.

Final thoughts

Tailwind CSS is a highly customizable and lightweight framework that offers a lot of flexibility and control over HTML elements. It improves the speed and efficiency of development and results in an optimized application. However, because of its highly customizable and non-semantic utility classes, Tailwind could take longer to get familiar with. If you found this article helpful, consider subscribing to our weekly newsletter and get expert insights delivered to your inbox.

Author: Pratik

Meet Pratik, a Drupal developer by profession. He enjoys reading and is always eager to learn new languages. Someday, he would love to visit Italy, his dream travel destination. He enjoys diverse cuisines and has a passion for food.

Drupal Drupal Development Drupal Module Drupal 9 Drupal Planet Subscribe to our Newsletter Now Subscribe Leave this field blank

Leave us a Comment

  Recent Blogs Image Creating custom design systems with Tailwind CSS and implementing it in Drupal Image Build marketing landing pages quickly and easily with Drupal 9 Image What to expect in Drupal 10 Want to extract the maximum out of Drupal? TALK TO US Featured Success Stories

Upgrading and consolidating multiple web properties to offer a coherent digital experience for Physicians Insurance

Upgrading the web presence of IEEE Information Theory Society, the most trusted voice for advanced technology

Great Southern Homes, one of the fastest growing home builders in the United States, sees greater results with Drupal 9

View all Case Studies
Categories:

Cocomore: Drupalcamp Zaragoza 2022: the deeply missed event is back!

Planet Drupal - Tue, 2022/06/07 - 11:49am

Drupalcamp Zaragoza 2022: the deeply missed event is back!

sandra.bloem Tue, 06/07/2022 - 11:49 Expanding virtual companies internationally
Categories:

Talking Drupal: Talking Drupal #350 - Accessibility Scanning & Testing

Planet Drupal - Mon, 2022/06/06 - 8:00pm

Today we are talking about Accessibility Scanning & Testing with Mike Gifford & Daniel Mundra.

www.talkingDrupal.com/350

Topics
  • Accessibility Scanning and Testing
  • Goals
  • Popular tools
  • Drupal tools
  • Storybook
  • VPAT
  • OpenACR
  • How it replaces VPAT
  • OpenACR and Drupal
  • Tackling Accessibility
  • Tools to use
  • Automation
  • CI/CD
  • Issues that will not be caught
Resources Guests

Mike Gifford - mgifford.medium.com @mgifford Daniel Mundra - danielmundra.com

Hosts

Nic Laflin - www.nLighteneddevelopment.com @nicxvan John Picozzi - www.epam.com @johnpicozzi Mike Herchel - herchel.com - @mikeherchel

MOTW

Editoria11y Editoria11y (“editorial accessibility”) is a user-friendly checker that addresses three critical needs for content authors

  1. It runs automatically. Modern spellcheck works so well because it is always running; put spellcheck behind a button and few users remember to run it!
  2. It runs in context. Views, Layout Builder, Media and all the other modules Drupal uses to assemble a complex page means checkers that run on individual fields cannot “see” errors that appear on render.
  3. It focuses exclusively on content issues: things page editors can easily understand and easily fix. Editoria11y is meant to supplement, not replace, testing with comprehensive tools and real assistive devices.
Categories:

Drupal Association blog: Strategic Initiatives Now Have Logos!

Planet Drupal - Mon, 2022/06/06 - 3:09pm

Strategic initiatives have been an integral part of Drupal’s growth as an open source project. Their goal is to solve impactful problems and foster continuous innovation through collaboration. While the community is busy working towards executing 7 of the current strategic initiatives, did you know they also have their own unique logos now? For those of you who missed taking a peek into the logos at DrupalCon Portland 2022, read on to find out!

Why logos for the initiatives

One of our goals as members of the marketing team for the Promote Drupal initiative was to build excitement among the community about the initiatives. More excitement means more involvement and contributions that can help push the strategic initiatives to the finish line faster.

But in a community as large as ours, not everyone is aware of the impact created by the strategic initiatives. 

Logos are memorable and create a long lasting impression. We wanted everyone in the community and beyond to connect with each of the initiatives. Having a logo will give them a visual identity that triggers a positive recall of what the initiative represents and how it makes them feel. Undoubtedly, the logos also serve as a great marketing asset for:

  • Prints
  • Presentations
  • Cons and events
  • Website
  • Shirts
  • Stickers 
  • ..and more
Designing the Logos

Every logo needed to tell a story behind the initiative. And who better than the initiative leads themselves to be the narrators? We reached out to the leads of each initiative to get their opinion on the logo design. A questionnaire survey was sent out in which we asked about their opinions regarding the initiative, what it meant to them, what they hoped it would accomplish, etc.

Based on the responses received, we drafted a design brief that included the goals and logo ideas of each initiative. We then collaborated with community member and product designer - Vinicius Custodio, who immediately commenced working on turning the ideas into reality (DrupalThanks, Vinny!). Take a look at the results.

Automatic Updates Initiative

The automatic updates Drupal logo signifies a constant and automatically updating project. It needed to express that automatic updates will make life easier for Drupal site owners. 

Drupal 10 Readiness Initiative

The logo ensures Drupal's longevity with updated components and a slimmed down core system. It represents the future of the web with a feeling of modern, fresh and cleaned up.

Decoupled Menus Initiative

The logo communicates the decoupled nature of the work and also ideally sets a pattern for logos for future decoupled initiatives. It also elegantly represents Drupal and the menu icon. 

Easy Out Of The Box Initiative

The logo emphasizes the “easy” part of Easy out of the box initiative. The brand new drop emerging out of the box represents ease, modernity and empowerment from the moment Drupal is installed.

GitLab Acceleration Initiative

The team was clearly looking for a mashup between the Drupal drop and the GitLab logo and this logo is a perfect blend of them both.

Olivero - New Frontend Theme Initiative

Olivero is a minimal but practical theme for Drupal. The idea behind the logo was to highlight its simplicity with clean shapes and clear typography. It needed to look modern, friendly and represent accessibility.

Project Browser Initiative

Project browser works like an app store for Drupal. The idea behind the logo was to skin the Drupal drop logo as a download button.

What are your thoughts on the logos? Let us know in the comments below. If you’d like to join the Promote Drupal team to help us create a variety of marketing assets for Drupal like these, learn more about getting involved.

And here’s a huge #DrupalThanks to all the initiative leads who collaborated with the marketing team to help build better material.

Categories:

clemens-tolboom commented on issue mdn/web-speech-api#61

On github - Mon, 2022/06/06 - 9:43am
clemens-tolboom commented on mdn/web-speech-api#61 Jun 6, 2022 clemens-tolboom commented Jun 6, 2022

@PROxZIMA that is not true. Browser based speech recognition does not need these keys.

Opensource.com: A Drupal developer's guide to Progressive Web Apps

Planet Drupal - Mon, 2022/06/06 - 9:00am
A Drupal developer's guide to Progressive Web Apps

Here is an outlined approach to PWA implementation for a Drupal site, but other options are certainly available with similar designs.

Alex Borsody Mon, 06/06/2022 - 03:00

The following article is a companion to my presentation at Drupalcon and Drupalcamp covering Progressive Web Apps implementations. Progressive Web Apps (PWA) have support from...

Categories:

Oomph Insights: Redesign & Relaunch: Oomph’s Color Accessibility Tool for Designers gets a Redesign

Planet Drupal - Mon, 2022/06/06 - 2:00am
It's been a long time since the Hack Day that launched ColorCube 1.0 — almost exactly 5 years, in fact. We are excited to have redesigned the tool to make it easier to use and to also give ourselves the opportunity to explore some new technology in the process. Say Hello to AccessibleColor.design Formerly called ColorCube, AccessibleColor.design (ACd) is a tool built by developers for designers. It's a tool that anyone can use, but the way it allows visitors to adjust colors to reach a passing threshold without the need for Photoshop or similar tools makes it perfect for designers. The…
Categories:

#! code: Drupal 9: Different Update Hooks And When To Use Them

Planet Drupal - Sun, 2022/06/05 - 8:54pm

I have written lots of detail about using update hooks to manage updates in Drupal and they have all been about the hook_update_N() hook. The hook_update_N() hook is just one of the options available in running updates as the update pipeline also includes hook_post_update_NAME(). The hook_deploy_NAME() hook, bundled with Drush 10, can also be used as an update hook in the same way.

Each of these update hooks has a number of different best practices when considering their use. All of these hooks are run once and once only and the key idea is that they take Drupal (or a module) from one version to another by adding database changes or configuration updates as the module gets updated.

For example, if you have a module that has a database table then it will be stored as schema information within your module. Once you release the module you must ensure that everyone who already has the module installed can still use it after the schema has changed. This means that as well as updating the schema information you also need to provide steps in the update hooks to update existing installs. Without this step the module would likely crash as it attempts to inject data into tables or fields that don't exist.

Update hooks can also be used to introduce changes to sites by managing configuration and content. This allows complex changes to be deployed in a clean and predictable manner. It can even be used to deploy content changes like adding menu items or taxonomy terms or even adding content to new fields.

Read more.

Categories:

Peoples BLOG: Drupal Configuration management (Local, Dev, Test and Live)

Planet Drupal - Sat, 2022/06/04 - 12:00pm
In this article we are going to see how Drupal serves configurations across the environments, which can be well maintained with help of some contributed modules and version control. Drupal 8 onwards configuration has been saved in the yml files in a consistent manner, which includes all the enabled modules, all the content types, vocabularies, fields & views. Making the configurations direct
Categories:

Vasily Yaremchuk: Free, Secure and Easy to Manage: Drupal Tome + Bookish + GitPod + Netlify

Planet Drupal - Fri, 2022/06/03 - 11:41am
Free, Secure and Easy to Manage: Drupal Tome + Bookish + GitPod + Netlify Vasyl Yaremchuk 06/03/2022

A few months ago I ran my separate blog site to share the idea of Open Source Literature.

It's based on the Netlify template for Tome projects with an awesome Bookish profile that is ideal for blogging. I'm not going to describe the pros and cons of that profile, you can read the fresh blog post "Meet Bookish, an install profile for static Drupal blogs" by Samuel Mortenson.

I can host static on Netlify for free. Usually, I ran my Tome installation locally, but it's not convenient, because I need to have a relatively powerful local machine with Composer and Drush installed locally. There is no ability to add a new post, say, from a tablet when I'm out without my laptop somewhere on vacation and so on. But now I use the workflow that completely gets rid of that limitation.

Let me explain how it works now.

You can fork the Netlify template for Tome projects and make the initial installation and setup locally. Please read the Official Documentation

Also, deploy your site on Netlify hosting. It's very convinient to use the link "Deploy to Netlify":
 

But you have to setup link to your repository in Reasdme.md:

[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/drupal-tome/netlify-template)

But can we work without local Drupal installation?

Now when I need to add a new post I use GitPod. I've register there with my GitHub account and I can run GitPos Workspace with any my repository. I'm selecting my open-source-literature.org repository:

After that, I have an awesome VS Code editor where I can customize theme and I have a one-time login link to admin:  

 

It looks like magic but you can run the installation of your site into the workspace, generate a one-time login link and run the webserver automatically, there is a file .gitpod.yml that allows setting commands when you run your workspace, you can align that file with your needs. There is default .gitpod.yml in the Netlify template for Tome:

image: mortenson/tome tasks: - init: | COMPOSER_MEMORY_LIMIT=2048M composer install [ -d content ] && drush tome:install -y command: | [ ! -d content ] && echo "Looks like you haven't initialized a Tome site yet - make sure to composer require any profiles you want to use, then run drush tome:init to get started!" [ -d content ] && drush uli -l $(gp url 8888) [ -d content ] && drush runserver 0.0.0.0:8888 ports: - port: 8888 onOpen: ignore

I can open a one-time login link in the new browser tab and make some edits:

 

When you've finished all your fixes you need to make some actions in the VS Code terminal:

 

- stop the server (^C),

- type $ drush tome:export -y to export changes from database to files,

- save changes to your repository

$ git add .

$ git commit -m "Your commit message."

$ git push

That's it! Your changes will be deployed to Netlify automatically!

Is there any limitation to such an approach? Sure, GitPod allows running workspaces up to 50h per month free. So don't forget to stop your workspace after you'll finish your edits:
 

 

Image
Categories:

Promet Source: How to Optimize Digital Experiences in Drupal

Planet Drupal - Thu, 2022/06/02 - 10:09pm
Digital experience or DXP is among the latest buzz words to have captured the attention and entered into critical conversations among marketers, website managers, IT professionals, and at times, even the entire C-Suite.  There’s, of course, good reason for heightened interest in digital experience. More often than not, the first interactions that customers and constituents have with companies and public sector entities these days are via digital channels. Quality DXP functions as an essential driver of loyalty and can serve as a significant contributor to the bottom line. 
Categories:

Community Working Group posts: Code of Conduct team update: June 1, 2022

Planet Drupal - Thu, 2022/06/02 - 8:10pm

As previously reported, the Community Health Team has started to have regular, bi-weekly meetings in an effort to develop and update the Code of Conduct for the Drupal community.

Community Health Team members present at this week's meeting were

Our first task was to review our project Miro board (a fancy virtual white board); further refining the tasks and their placement (categories).

We then had a discussion about how best to expand the initial team while still keeping focus. We plan on inviting more community members to participate on specific tasks (including reviewing milestones along the way) at different points in the process in an effort to find and fix potential issues as early as possible. Our discussion led to an initial list of groups we plan on inviting to this process at various stages:

  • Security working group
  • Event organizers working group
  • Drupal Diversity & Inclusion
  • Core committers
  • Top Drupal contributors
  • Top contrib project maintainers
  • Community accessibility experts
  • Various geographic-based groups

We are all in agreement that including non-United States and non-Western European community members as part of this process is a high priority for us. Identifying and contacting community members willing to help will be an early task of ours. This work will begin during the next two weeks.

Our second task for the next two weeks will be to start the process of individually reviewing our existing Code of Conduct as well as those of other communities and sharing relevant feedback at our next meeting.

If you have suggestions for who should be involved in the overall process of updating our Code of Conduct, please let us know in the comments below.

Categories:

Drupal Association blog: Honoring and Celebrating our DrupalCon Portland 2022 Scholars

Planet Drupal - Thu, 2022/06/02 - 3:29pm

Recently at DrupalCon Portland 2022, I was honored to share space with our amazing scholarship recipients at our Scholarship Breakfast and throughout the rest of the week. This community building felt particularly meaningful, as it was our first year gathering in person again since 2019 and for many of our scholars, it was their first DrupalCon ever! 

The DrupalCon scholarship program exists to decrease barriers-to-entry for marginalized people in the Drupal community and contributing to the project. Scholarship programs like these are not charity, they are providing the resources for historically oppressed folks in our society and community who deserve as much success and access as those of privileged identity. 

In addition to the 2019 Driesnote, we were grateful to host industry leaders at DrupalCon Portland 2022 to discuss inequity in Open Source. From the background and framework of understanding to actionable progress that can be made, I feel confident and energized that the Drupal community is on the right track. 

A reality for marginalized folks worldwide is that not all scholarship recipients can be featured publicly. There are very real risks to living in our truth publicly, and I take the safety and privacy of our scholars very seriously. Consent and personal autonomy are everything! 

Of our scholars who consented to being featured, I asked if they’d like to share their experiences with us, and 3 of them have graciously agreed. All 3 of them are some of the warmest folks I’ve ever spent time with as well as being powerhouse professionals doing incredible work in Drupal. We are all made better by being in community with them.

Kwame “pearcraft” Puryear 

How he got into Drupal (and why he stayed) 

I started following the Drupal community fifteen years ago, after hearing about it on the Lullabot podcast. The cooperative nature of the Drupal community stood out to me - in fact, it aligned well with the principles of Kwanzaa that I had learned from my family throughout my life.

His experience at DrupalCon Portland 2022 

My mentor, Leslie Glynn gave me excellent advice on how to get the most from DrupalCon. My favorite moment was Dries promoting my volunteer project (Project Browser) as a major feature of Drupal 11! My favorite session was Dori Kelner's "You Are Not A Fraud". Its focus is on Imposterism in general and how it’s actually MORE devastating for talented people. It also highlighted how it specifically affects disadvantaged groups of people.

Allison Lu 

How she got into Drupal (and why she stayed)

I worked with Drupal 8 while building out UCLA's Undergraduate Admission website. Currently, I’m working with Drupal 9 on VA modernization. I want to meet more women in tech! I like digital accessibility, and connection.

Her experience at DrupalCon Portland 2022

One piece of advice from my mentor (Em Nouveau) that stuck with me was to go to the Birds of a Feather sessions, since all talks are recorded but these organic small group discussions weren't. I joined the Drupal Diversity and Inclusion (DDI) table, where I felt truly welcomed as a different and beginner Drupal developer. Along with this experience, the warmth of the Drupal Association folks and insight of the diversity keynotes were so validating, healing, and empowering. 

Lapedra Tolson 

How she got into Drupal (and why she stayed) 

Federal agencies use Drupal for their content management systems a lot. I founded Friends From The City because I wanted to be the change I wanted to see in the world. Friends From The City is a digital services firm that partners with federal and state agencies to modernize their legacy systems, and Drupal is heavily used. We often try to design a bespoke user experience for authors and editors rather than using out-of-the-box templates, specifically at the U.S. Department of Veteran Affairs.

Her experience at DrupalCon Portland 2022 

DrupalCon Portland 2022 was an amazing conference. Von Eaton is an awesome person who is welcoming and affirming. After the scholars' breakfast (which was delicious, btw) and the sessions, I felt inspired to learn more about Drupal, particularly as the founder of a design firm. In addition to the informative sessions, meeting new people at the various networking events was also a pleasant experience. I hope to attend more DrupalCons in the future and continue to learn about this awesome platform and community. Thank you for welcoming us!

I also want to lift up our other scholarship recipients who consented to being featured publicly: 

Thank you so much to all of you for choosing to spend your week at DrupalCon Portland 2022 and for all you do to make an impact on those around you. I am deeply grateful to know you all, and I look forward to continuing to support you in your Drupal journeys. 

If you’d like to read more about Diversity, Equity, and Inclusion trends in open source, here are some great scholarly articles: 

Categories:

mark.ie: Creating a Drupal Field Group Programmatically

Planet Drupal - Thu, 2022/06/02 - 3:26pm

How to create a Drupal field group programatically in Drupal 8, 9, 10, etc.

Categories:

Droptica: Enhanced Drupal templates. Review of the Twig Tweak Module

Planet Drupal - Thu, 2022/06/02 - 2:23pm

When using any kind of solution, we usually encounter the need to create generic support functions. A similar situation occurs when working with templates in Drupal 9. If you’ve ever created custom code to display a block, view, or entities in a Drupal 9 template, and are interested in ready-made and tested solution, this article is for you. We’ll show you the Twig Tweak module, which provides a number of support functions.

Twig and Drupal

Twig is a template engine for PHP, released in 2009. It’s constantly developed. As at the date of writing this article, the latest version is 3.4.1. Twig is an integral part of the Symfony framework, and thus – also of Drupal 9. Drupal in its own way implements certain concepts, such as entities, blocks, and views. To build the final HTML from the so-called render arrays, Drupal uses internal classes designed for this purpose. Twig, however, doesn't know by default how they work. Because of this, it’s natively impossible to, for example, render a block or view with any parameters and in any place just by using the Twig engine. To make such an operation possible, the Drupal community has created the Twig Tweak module, which introduces a substantial list of Twig extensions addressing the most common Drupal-specific problems.

Twig Tweak module

The module was released on 3 January 2016, and its latest update was on 15 April 2022. Twig Tweak has an older version that is compatible with Drupal 8 and 9, and a newer one that requires Drupal 9. For obvious reasons (using Symfony from version 8), the module doesn't have a Drupal 7 version.

The Twig Tweak module provides a collection of extensions for Twig that allow you to, for example, render views, blocks, regions, entities, fields, menus, forms, tokens, and more. The full list of possibilities is provided in the Twig Tweak cheat sheet prepared by the authors.

Twig Tweak is currently used by over 100 thousand websites. The latest 3.x version is gaining in popularity over the older 2.x version, which is experiencing slight but continuous drops.

 

Source: Drupal.org

The creator and the main person maintaining the module is the user Chi. Due to the popularity of the module, the full list of people who contributed to its development is too extensive to be quoted.

Installation

The Twig Tweak module's installation is standard.

composer require drupal/twig_tweak drush pm:enable twig_tweak

The module has no dependencies other than Drupal Core and also doesn't provide custom permissions.

There is one configuration option - twig_tweak_enable_php_filter - which is set in the settings.php file. It is set to TRUE / FALSE and is FALSE by default. Enabling this option adds the possibility of using pure PHP in Twig. The option is turned off by default, possibly for security reasons.

How to use Twig Tweak

After installing the module, we get access to the following functions:

drupal_view

Renders the provided view. Example: 

{{ drupal_view(‘view_id’, 'view_display_id’) }}

drupal_view_result

Renders only the result of the provided view. Example: 

{{ drupal_view_result(‘view_id’, 'view_display_id’) }}

drupal_block

Renders the provided block. Example:

{# Block with default configuration. #} {{ drupal_block('block_id') }} {# Block with custom configuration. #} {{ drupal_block('block_id', {config_id: 'foo', another_config_id: false}) }} {# Block without block.html.twig theming. #} {{ drupal_block('block_id', wrapper=false) }}

drupal_region

Renders the provided region. Example:

{# Foo region of the default theme. #} {{ drupal_region(‘foo’) }} {# Foo region of Bartik theme. #} {{ drupal_region('foo', 'bartik') }} Other functions in Twig Tweak

Let's take a look at other options available in this module:

drupal_entity - renders entities,

drupal_entity_form - renders entity form,

drupal_field - renders field,

drupal_menu - renders menu,

drupal_form - renders form,

drupal_image - renders image,

drupal_token - replaces token,

drupal_config - renders configurations,

drupal_dump / dd - renders a readable version of the variable's content (helpful for debugging),

drupal_title - renders the title of the current page,

drupal_url - renders URL,

drupal_link - renders link,

drupal_messages - renders status messages,

drupal_breadcrumb - renders breadcrumbs,

drupal_breakpoint - triggers the Xdebug's breakpoint,

drupal_contextual_links - renders contextual links.

Filters in the Twig Tweak module

Now we'll take a look at the filters available in the tool:

token_replace - replaces token,

preg_replace - enables using the preg_replace function in Twig,

image_style - applies the given image style,

transliterate - transliterates text from Unicode to US-ASCII,

check_markup - filters text based on the text style specified in the system,

format_size - formats the given number of bytes into a character representation with a multiple suffix,

truncate - limits the given text to the chosen number of characters,

view - returns the render array for the given entity or field,

with - works inversely to the core's without filter,

children - used in multiple-selection fields to get a list of items,

file_uri - returns the URI of a given media file,

file_url - enables using the file_url function in Twig,

translation - returns the translation of a given entity,

cache_metadata - adds cache metadata to the printed field,

php - executes the given string of characters as PHP code.

You can find a detailed description of the filters together with examples of use in the above-linked Twig Tweak cheat sheet.

Twig Tweak module - summary

The Twig Tweak module saves time and opens up new possibilities for developers. The filters and functions it provides are useful in everyday work with Twig. The module is very popular, well-supported, and willingly recommended by the community. As a team of Drupal developers, we recommend installing and trying out the possibilities provided by the Twig Tweak module.

Categories:

Samuel Mortenson: Meet Bookish, an install profile for static Drupal blogs

Planet Drupal - Thu, 2022/06/02 - 10:00am
For the last four years I’ve been working on a static site generator for Drupal called Tome. Unlike other generators Tome uses “vanilla” Drupal, which means that if you know how to build a Drupal site, you know how to build a Tome site! One downside of this is that when comparing a default install of Drupal with a default install of something like Gatsby, Drupal looks pretty outdated. I wanted to show Tome off but couldn’t do it well with core, so I decided to focus my energy on a new install profile for static blogs - Bookish.
Categories:

PreviousNext: The right way to check for empty content in Twig

Planet Drupal - Thu, 2022/06/02 - 7:39am

Have you ever used {% if content|render|trim is not empty %} in twig to validate content is not empty?

If so, you might end up with some surprises related to the use of the render method.
 

by mohit.aghera / 2 June 2022 Introduction

Checking that content is not empty before rendering is good practice. Typically we call the “trim” method as well so all the space gets trimmed and we get an accurate indication if the content is empty.

Usually, developers uses snippet like {% if content|render|trim is not empty %} to ensure that content is not empty.

Recently while working on one of our projects, the client informed us that Webform was having issues with Recaptcha and was throwing errors related to invalid tokens. To debug further, we disabled recaptcha handler and saw that Webform submissions were being recorded twice.

While debugging further, we noticed that all the things were working as expected for Webform and simple_recaptcha module’s Webform handler. So both of those causes were out of the picture.

We'd experienced a similar issue before, and in that case the cause was a [node:description] tag from Metatags that was rendering the embedded Webform. At first we thought this might have been the case, but debugging revealed that Metatags was not in the mix this time.

During debugging further around rendering process, we noticed that render() was being called twice. Rendering twice was causing issues with recaptcha tokens. Because the second render was invalidating the original recaptcha token.

Upon debugging further we found the following twig templates code was causing issues. 
 

​​{% if content|render|trim is not empty %} 
 
  
 {{ content.content }} 
  
 
{% endif %} 
 

Here, if you notice the block {% if content|render|trim is not empty %} that we are calling render method of TwigExtension.php. So this was rendering the content the first time and then the second time we are actually rendering the content using {{ content.content }}. So this second render was invalidating the previous token generated by the Webform handler.

Solution

As the use of the render function was causing issues we need to use a different approach to validate the issue.

In such situations twig’s set tag comes to the rescue.

We can use it in conjunction with the spaceless twig filter to only render the content once. The spaceless filter makes sure we don't get a false positive from whitespace, just like the trim function did before.

So we can refactor above twig snippet using the set tag and the spaceless filter like this:

{% set content_render %}{% apply spaceless %}
 {{ content.content }}
{% endapply %}{% endset %}
{% if content_render is not empty %}
 
   
     {{ content_render }}
   
 
{% endif %}

By using this approach, we can achieve the same thing as the original approach, but with only one render.

Conclusion

The set tag in conjunction with the spaceless filter allows us to safely render a variable, remove any whitespace between HTML tags and then use that as a variable to evaluate if the output is empty. If not, we can just output the already-rendered variable and in doing so avoid additional render in our twig templates. 
 

Tagged Drupal Development, Theming, Drupal Theming, Twig
Categories:

Liip: Liip revolutioniert das Lohnsystem

Planet Drupal - Thu, 2022/06/02 - 12:00am

Das neue Lohnsystem der selbstorganisierten Digitalagentur Liip gewinnt den Swiss HR Award in der Kategorie “Diversity, Inclusion, Equality”. Der Liip Deal stellt Mitarbeitende ins Zentrum. Ganz nach dem Motto digital, human progress wird die agile Weiterentwicklung zugänglich gemacht, denn viele fortschrittliche Organisationen stehen vor dem Schritt, neue Lohnsysteme einzuführen.

Der Swiss HR Award

Der Swiss HR Award zeichnet jährlich innovative Projekte in der “People-Welt” aus. Die Inhalte der Arbeiten müssen kreativ neue Wege beschreiten, mutig Neues ausprobieren und Wirkung zeigen - mit effektiven Resultaten. Der Swiss HR Award setzt damit Qualitätsstandards für Arbeitsmodelle und zukunftsweisende Ideen im HR Bereich. Die Fachjury beurteilt Projekte in sieben Kategorien. Mit dem neuen Lohnsystem wandelt Liip die Kultur und setzt sich aktiv für ein System ein, welches Diversität, Inklusion und Gleichstellung fördert.

Von link nach rechts: Zahida Huber, Sergio Mendolia, Nadja Perroulaz und Pascal Helfenstein

“Selbstbestimmung, Gleichstellung und Klarheit in der Entschädigung war unser Ziel. Das war nicht immer einfach zu balancieren. Aber wir haben es geschafft, ein System zu kreieren, dass zur Selbstorganisation passt und die Mitarbeitenden ins Zentrum stellt”. So Sergio Mendolia, Fullstack Developer and Salary Process Developer bei Liip.

Das neue Lohnsystem - der Liip Deal

Ein gleichberechtigtes Lohnsystem, das keine Unterschiede zwischen Berufsbildern und möglichst kleine Lohnunterschiede macht, das lebt Liip schon seit der Gründung. Um am Ball zu bleiben, entwickelt das Digitalunternehmen sein Entlöhnungssystem kontinuierlich weiter. Das Lohnsystem wurde 2016 entwickelt und basiert auf dem Konzept der Peer-Evaluation. Seit 2018 sind das System sowie die daraus resultierenden Löhne vollständig transparent: Alle Mitarbeitende wissen, wer was verdient und wie der Lohn berechnet wird; das bleibt auch so. Das neue System basiert auf 2 Kriterien mit jeweils 6 Stufen, Ein Basissalär basierend auf den Lohnrechner bildet die Grundlage. Mitarbeitende schätzen darin selbst ihre Expertise und den erzielten Impact ein, welcher dann von mindestens 2 Kolleg*innen überprüft und kommentiert wird. Das Alter und die Loyalität dazugerechnet, entsteht der individuelle Lohn.

Jurypräsident Jörg Buckmann übergibt den Swiss HR Award an Sergio Mendolia und Pascal Helfenstein

“Agiles Arbeiten gehört auch bei internen Veränderungen zum Standard. Wir teilen unsere Erfahrungen bewusst mit agilen Organisationen und anderen interessierten Unternehmen, denn Open Source ist in unserer DNA. Es macht Spass, mit solchen Projekten aktiv etwas zu bewegen.” sagt Pascal Helfenstein, Software Engineer und Salary Process Developer bei Liip.

Mitarbeitende im Zentrum des neuen Lohnsystems

Was ist revolutionär am neuen Lohnsystem von Liip? Es ist auf agile Organisationen zugeschnitten, impliziert eine hohe Eigenverantwortung und ist Zweck- und Wirkungsorientiert. Ein Lohnsystem also, das nicht verhandelbar ist, auf Selbst- und Peer-Evaluationen basiert und transparent ist. Alle Mitarbeitenden - auch die ehemalige Geschäftsleitung - werden in das System eingebunden. Es gilt die gleiche Bezahlung in allen Funktionen durch das Basissalär. Zusätzlich dazu werden höhere Gehaltsstufen mit der Expertise und Wirkung erreicht. Zudem macht Liip als Arbeitgeberin explizit, dass Mitarbeitende nicht nur mit ihrem monatlichen Gehalt entlöhnt werden, sondern mit einem ganzen Paket, dem “Liip Deal”.

“Mit unserem “Liip Deal” haben wir ein in der Schweiz neues und einzigartiges System entwickelt. Alle Prozesse und Systeme wurden von Grund auf neu definiert und entwickelt. Mit dem Lohnrechner als Basis bleiben die Löhne marktgerecht. Und wir nehmen die Mitarbeitenden in die Verantwortung, denn sie starten eine Lohnveränderung mit der Selbstevaluation”, sagt Nadja Perroulaz, Mitgründerin von Liip.

Die Digitalagentur freut sich sehr über die Auszeichnung am diesjährigen Swiss HR Award.
Mehr zum Thema: liip.ch/de/blog/salary-system-liip
Der Podcast des Agile Breakfast: swissict.ch/agile-breakfast-kompakt-002-mit-nadja-perroulaz

Categories: