Articles list

Vite throwing ESM error during build

Posted on
I had an issue where I tried to upgrade a Vue project which was built on vue-cli to use Vite instead. Things were fine until I tried to include Tailwind plugin for Vite.

Writing my first browser extension with WXT

Posted on
In the last few months, I have worked on expanding my knowledge in web development by learning new technologies. I explored more of the Vue.js world and played around with many new libraries and patterns. Meanwhile working on work stuff I missed a good (or more suitable for me) extension that can fill forms with test data so I decided to put two things together - wanting to learn something new and improve my development workflow.

How to implement File Validation events?

Posted on
Drupal 11 will change many functionality related to file validation. One of the changes is the hook_file_validate() which is now deprecated and will be removed from Drupal 11.

Should you use Gin admin theme in Drupal?

Posted on
Are you considering a different admin theme for Drupal, because you dislike Claro? Maybe you are looking for something more modern? There is a contributed theme, which has good support and is currently one of the popular themes - Gin

Composer dependencies in VCS

Posted on
The best practice for composer dependencies is to keep them ignored in VCS. On some rare occasions, you may need to keep them there. So, how to do it correctly?

Show field on entity form programmatically

Posted on
How do you update entity display mode to show a newly created field by default? It is easy with configuration import, but what if you need to use hook_update_N?

What are guard clauses?

Posted on
Programming can be considered as a form of art - like each artist does its own thing it is the same with coding style - each for their own. Sometimes you learn from others, and sometimes you discover it yourself or you combine different ways and see what works well and what does not.

What is once() in Drupal and do you still need it?

Posted on
JavaScript plays a crucial role in modern web development, enhancing the interactivity and user experience of websites and web applications. In the context of Drupal, a powerful and flexible content management system, JavaScript is utilized to create dynamic and responsive interfaces, making websites more engaging and user-friendly.

How to name fields in Drupal

Posted on
The hardest thing in software development - is naming. Whether it is a variable, class name, or field naming in Drupal, it might be complicated. I'll write about my naming convention in Drupal that I will use daily basis and what are the benefits.

Importing translations in Drupal

Posted on
Drupal has good multilingual support out of the box and it allows to creation of multilingual sites easily. In normal circumstances translation process is easy, but there are some cases where you may want to update translations programmatically.

PHP enum values as an array keys

Posted on
Enums allow a developer to define a custom type that is limited to one of a discrete number of possible values. Using it as an array key was not that straightforward.

Backup website database to Google Drive

Posted on
I needed a basic solution to back up the website database into Google Drive, just to have some backups in case something bad happens.

Entity query parameters are language dependent

Posted on
I have worked on multilingual Drupal sites quite a lot but some things still come as a surprise. I have used entity query in some cases but today I did encounter an issue where something did not work correctly.

Using CacheableMetadata in Drupal

Posted on
The Cache API is a powerful feature of Drupal, but it might be hard to figure out how to use it correctly. Over time I have seen different ways to do it, but I believe there is a method better than others.

Breaking configuration in Drupal

Posted on
One of the strongest features in Drupal is configuration management. While it is reliable functionality, you can actually break it.

How to use Drupal once()

Posted on
Drupal implements its own Javascript API. Most of the time, all code should use behaviors that trigger every time something changes on the page - page loaded, ajax request, and so on. On the other hand, it causes issues with code executing more than one time.

How to create a custom logger channel in Drupal

Posted on
Logging is convenient for storing information about important events in the application. You could use it to find out if any errors occurred, debug issues, and any other important information. In this article, you can find an example of creating and using it in dependency injection.

How to add container around CKEditor table

Posted on
Tables can be hard to make responsible. Bootstrap, for example, needs a special div wrapper, but it's not easy when dealing with CKEditor. Here you can find the filter plugin that created div around table elements.

How to hide taxonomy term paths from public

Posted on
Drupal shows all taxonomy term pages as publicly available and lists all related content. In this article, you will find an event subscriber to deny access by default and hook implementation to enable it for some taxonomy terms.

Choosing entity options for best performance in Drupal

Posted on
In Drupal, it is possible to create entity types with multiple options - with or without revisions, fieldable or not and these options have a different performance impact when dealing with functionalities that handle a large number of entities in a single process, so you would want it to be as fast as possible.

Drupal Views performance

Posted on
Views is a core module that has ability to create simple to complex listings from entities. It is possible to optimize them depending on use cases. Let's cover them.

Modifying module configuration in update hook after enabling

Posted on
Depending on the type of your project, you may need to deal with update hooks which enable modules programmatically and then modify their configuration. When dealing with configuration updates with hook_update_N(), there is one thing to look out for related to enabling modules programmatically.

How to migrate from jQuery.once()

Posted on
Drupal 10 removed old jQuery.once() plugin and replaced it with separate library in plain JavaScript. Existing scripts need to be updated, but there are some things to look out and they won't work as it might be assumed.