Vanilla JavaScript equivalent of jQuery click

13 Jan, 2023
In vanilla JavaScript, the equivalent of the jQuery click function would be the onclick property. The onclick property in JavaScript is an event property of HTML elements that allows you to specify a...

in_array equivalent in JavaScript

12 Jan, 2023
In JavaScript, the equivalent of the PHP function in_array() is the includes() method, which is used to check if an array contains a certain value.

Get all nodes with attribute that exists in xPath

10 Jan, 2023
Get all nodes that have a defined attribute in xPath. Explanation of commands: "//" selects nodes in the document from the current node that match the selection no matter where they are."*" is a...

Vanilla JS equivalent of jQuery prepend

2 Jan, 2023
Insert content to the beginning of an element. Vanilla JS equivalent prepends to a single element, to prepend to multiple elements you need a loop. Same applies to append.

Vanilla JS equivalent of jQuery find

30 Dec, 2022
The Vanilla JavaScript equivalent of jQuery's .find() method is the .querySelectorAll() method. The function allows us to search through the descendants of these elements in the DOM tree and...
Apache logo

Redirect all subdomains to main domain using .htaccess

13 Nov, 2022
Redirect all subdomains to main domain using .htaccess. Using some sort of a mass-hosting provider, you never know what they might change in your DNS automatically. This is a backup solution to make...

Convert time to utc from timezone in PHP

11 Nov, 2022
Working with timezones can be tricky and if you do migration of data from/to somewhere. You might have to correct timezones. This snippet shows how you can change dates based on timezone difference.
Drupal 9

Iterate through entities in Drupal 9

11 Nov, 2022
You can iterate through entities using entitiyQuery. In this simple snippet you can see that the only condition is type. So using this exact one you can iterate through entities in a certain node...
Drupal 9

Get node url in Drupal 9 Twig

31 Oct, 2022
You need to get content url using path, to make sure all translations work and you are going into the correct absolute path. This snippet shows how to get link for nodes by id.
Drupal 9

Paragraphs from csv in Drupal 9

27 Oct, 2022
Create and add paragraphs programmatically to nodes. After trying to use migrate and feeds. Including migration from field collection to paragraphs or ECK. The final solution for me was to do it...