Goodbye preprocess functions! Welcome to drupal 8. We use a nice plug-in to get control over our menu item and to show html inside the title. In this case we show a counter of the amount of messages a user has.
A thing developers can forget while testing, is to make sure all functionality of your module is stable when used in the context of ajax. Some plugins might stop working after an ajax call on the page. This is how to prevent such thing.
One thing that bothers me quite a lot is the error when you try to import existing configuration into a new drupal 8 website. I resolved this by adding a custom drush command that gets fired right before config import.
When using content moderation, the view_unpblished module does not work. But I really needed to get a user role to see all nodes created of this type and have access to it. With the following snippet, I fixed this.
I encountered a problem while working on a big migration. The client wanted to reuse files and images, so I added entity browser functionality. The problem however was that views does not provide a preview image for files. Therefore I created a small module.
Drupal 8 is becoming more and more API-first based. This means a lot of imports and exports of data will be done. A thing you might face here, is that the updating of entity reference fields is a bit tricky. Here I'll show you how it is done.
Configuration management is great. But you'll encounter some difficulties at first when importing existing config to a new site. A typical error is the "Entities exist of type" error. Here's how to fix them.
Today I have a small helper module to share with you. A small pain in the ass is that the sending of e-mails requires a bit too much code. More specifically sometimes you would like to send simple alerts to webmasters. This helper module helps you with it.
Block access is a powerful way to show or hide content in some contexts. Instead of using contrib modules, this is very easy in small pieces of custom code. The following code prevents access to a block based on a subscription field in the user object.
When editing notes, an often mentioned problem of webmasters is the lack of preview of their text. With this snipped you can embed the css of your theme in CKEditor, which makes it much more visible towards your webmasters.
When a drupal site has different domains for its language, difficulties can arise when developing locally. With this snippet, you override your language settings, so prefixes are used instead of domains.
I personally like using the drupal menu block module. It allows for quick creation of submenu's. The following patch fixes a bug that keeps showing regions, even when there are no subitems in the menu block.
A typical setup is one where you would redirect all non www and http requests to https://www.domainname.com. I prefer to keep my .htaccess file in version control also. With the following snippet, I get it the way I want it.
In this case I created a custom entity called 'submenu'. In my custom module a used HOOK_LINK_ALTER to make the submenu (which contains a textfield) visible on hover. I used the code below to render my custom entity content:
When using lazy loading of images, I encountered an important issue. Social sharing engines like Facebook can't read placeholder images. In this drupal 8 tutorial we'll fix this issue by creating a small custom module handling image tokens.
Ever looked at Pinterest or Google images and wondered how to achieve this nice effect of loading in images? One of the things that frustrated me building drupal websites is the lack of nice front-end libraries. Fancyload solves the problem!