Drupal 9+

Drupal versions built on Symphony Framework.

Drupal 9

Clearing Cache in Drupal 10

28 Apr, 2023
The snippet shows how to clear Drupal 10 cache programmatically. You can do that for all of the cache or one by one using the ID of the cache that you want to clear.
Drupal 9

Get Full/Absolute URL in Drupal 10

27 Apr, 2023
Get the full/absolute URL of a page in Drupal 10 using the Url class. This snippet covers how to get the URL of the current page, a specific route, or an external website, and how to convert the URL...
Drupal 9

Load a File by URI in Drupal 10

27 Apr, 2023
Load a file entity in Drupal 10 by using its Uniform Resource Identifier (URI). This snippet provides a simple code example that demonstrates how to load a file entity by URI and check if it was...
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.
Drupal 9

Get all languages in Drupal 9

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