1 February

Functions file_create_url() not working in Drupal 10
By: admin | Published On: Thu, 02/01/2024 - 11:44

Functions file_create_url() was using to create url of images and files drupal 9 but now its not working in Drupal 10 so its deprecated now you can use code as follow to create url in Drupal 10




Used in Drupal 9 and before Using Drupal 10 file_create_url($uri) \Drupal::service('file_url_generator')->generateAbsoluteString($uri)…

13 December

entityQuery not working return error in Drupal 10
By: admin | Published On: Wed, 12/13/2023 - 21:49


I am using entityQuery to get Node by using following method

		$query = \Drupal::entityQuery('node');
		$query->condition('type', 'tours'); // Limit the type of node to check
		$nids = $query->execute();

but its return following error

Drupal\Core\Entity\Query\QueryException: Entity queries must explicitly set whether the query should be access checked or not. See Drupal\Core\Entity\Query\…

30 October

How to remove trailing slash from URL Drupal 10
By: admin | Published On: Mon, 10/30/2023 - 16:26

You can remove trailing slashes from URLs using the .htaccess file and mod_rewrite

Add the following code to your .htaccess file to Remove Trailing slashes from all URL of website.


RewriteRule ^(.*)\/(\?.*)?$ $1$2 [R=301,L]

This code will remove the trailing slash from URLs and issue a 301 redirect, so if someone accesses a URL with a trailing slash, they will be redirected to the same URL without the trailing slash.

Make sure you have the…

21 September

Get error undefined method File::url() in Drupal 9
By: admin | Published On: Thu, 09/21/2023 - 16:44

I was trying to create a custom banner based on user uploaded image in node then I got following error in Drupal 9 but it was workiing in Drupal 8  

Following code I was using

$img_url = $file->url();

Getting this error

Error: Call to undefined method Drupal\file\Entity\File::url() in theme_preprocess_page() 

I found the solution its working fine in simply use createFileUrl(); instead of url();


31 July

Update node field value of a content type using batch process in Drupal 9
By: admin | Published On: Mon, 07/31/2023 - 17:02

To update the text field value of a content type in Drupal 9 using a batch process, you can follow these steps:

Create a custom module: If you don't have one already, create a custom module in the 'modules/custom' directory of your Drupal installation.

Define a form to receive the user input: Create a form in your custom module that takes the new value for the text field as input from the user. This form will be used to trigger the batch process.

Implement the batch…

27 July

How render term field on node template in drupal 9
By: admin | Published On: Thu, 07/27/2023 - 16:56

In Drupal 9, you can render a term field on a node template using the field_view_field() function. This function takes the following parameters:

Entity type: The type of the entity (in this case, it's "node"). Entity: The node object that contains the term field. Field name: The machine name of the term field you want to render. Display mode: The view mode you want to use to render the field (e.g., "full", "teaser", "default", etc.).

Here's an example of how to render a term…

23 June

Set default value user name in user login form using form alter drupal 8
By: admin | Published On: Fri, 06/23/2023 - 08:53

To set a default value for the username field in a user login form using a form alter hook in Drupal 8, you can use the following code:

 * Implements hook_form_alter().
function yourmodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ($form_id === 'user_login_form') {
    // Set the default value for the username field.
    $form['name']['#default_value'] = 'your_default_username';

Replace 'yourmodule' with the…

1 June

What is the purpose of Ctools in Drupal 9
By: admin | Published On: Thu, 06/01/2023 - 17:53

In Drupal 9, Ctools (Chaos tools) is a suite of developer tools and APIs that provide various functionalities to enhance and simplify module development. Ctools is not specific to Drupal 9 and has been widely used in previous versions as well.

The primary purpose of Ctools is to provide a set of reusable utilities and APIs that help developers build complex and interactive features in Drupal. Some of the key features and purposes of Ctools in Drupal 9 include:


1 June

What are the benefits of using Drupal
By: admin | Published On: Thu, 06/01/2023 - 17:18

Drupal is a powerful and flexible open-source content management system (CMS) that offers numerous benefits for website development and management. Here are some of the key benefits of using Drupal:

Flexibility: Drupal provides a highly flexible and extensible framework that allows developers to build websites and applications tailored to specific needs. It offers a wide range of modules, themes, and APIs, enabling the creation of custom functionalities and designs.

1 June

Show Related Content by Category Using Views Drupal 8 or 9
By: admin | Published On: Thu, 06/01/2023 - 11:20

Follow these step to make block using views to show the related content according to category of the current content page.

Edit the views and open Advance section

Add the  'Content: Has taxonomy term ID' in CONTEXTUAL FILTERS. Check 'Provide default value' option and then select the 'Taxonomy term ID from URL'.


3.     Check the 'Load default filter from node page, that's good for related taxonomy blocks' option.

4.     Check the 'Limit terms by…