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...
PHP

Convert time to utc from timezone in PHP

11 Nov, 2022
PHP
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...
Drupal 9

Drupal 9: Redirect all traffic to https with .htaccess

23 Oct, 2022
Using .htaccess to force redirect traffic from http to https is the most simple way in Apache. If you have more access to your server, you can do it in VirtualHosts configuration. With redirecting...
Drupal 9

Get view url in Drupal 9 Twig

12 Oct, 2022
Instead of hard-coded URL, it's better to use URL function so the other data url parameters/data won't be lost.
Twig

string to upper in Twig

12 Oct, 2022
The upper filter is used to convert a string into uppercase. This function takes a string as parameter and converts all the lowercase alphabets present in the string to uppercase. All other numeric...
Drupal 9

Get all languages in Drupal 9

10 Oct, 2022
Gets the list of languages set up on the site.
React

useRef hook in React

27 Jul, 2022
The useRef Hook allows you to persist values between renders. First example would be to use the hook to update values without causing the component to re-render.