Drupal versions built on Symphony Framework.
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.
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...
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...
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...
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.
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: 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...
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.