logo

Blog

13 December

Install PDF using mPDF module using mpdf library in Drupal

Published On: Fri, 12/13/2024 - 16:03

Step 1 Download module "PDF using mPDF" from https://www.drupal.org/project/pdf_using_mpdf and install this module as normal process to installing module in drupal.

First you need to install library "mPDF" using compser to enable module "PDF using mPDF"

Step 2 start putty and connect through composer login detail

Now start command line type cd public_html and press enter, if your project in any other folder then again have to use same command using folder name then.…

8 December

List of common Node Variables in node.html.twig in Drupal 10

Published On: Sun, 12/08/2024 - 01:38

In Drupal 10, when working with the node.html.twig file, there are several useful variables available for rendering nodes. These variables provide access to the node entity, fields, metadata, and other useful information, making it easier to customize the way content is displayed.

Here’s a list of common Node Variables in node.html.twig in Drupal 10:

Core Node Variables

node: The full node entity object. You can use it to access any properties or fields of the…

4 September

Get node id of current node page Drupal 10

Published On: Wed, 09/04/2024 - 12:11
	$node = \Drupal::routeMatch()->getParameter('node');
	if ($node instanceof \Drupal\node\NodeInterface) {
	  // You can get nid and anything else you need from the node object.
	  $nid = $node->id();
	}

25 August

PHPMailer using composer in PHP or Drupal

Published On: Sun, 08/25/2024 - 21:08
Connect to your account via an SSH client. Open PuTTY and enter your SSH information in the Host Name (or IP address) and Port fields. Then, click Open. Once a command window appears, type in your SSH username and password and hit Enter. Remember that PuTTY will not display the password, so don’t be surprised if it doesn’t appear on the screen. Execute the following command to navigate to the public_html directory:
cd public_html
Run the following command to install…

20 August

node template cheat sheet Drupal 9 and Drupal 10

Published On: Tue, 08/20/2024 - 22:36
How to get field value of content type on node.html.twig

Get image field value at node.html.twig at Drupal 9 / 10

{{ file_url(node.field_image.entity.fileuri) }}
{{ node.field_image.alt }}

Get node crated date at node.twig.tpl

{{ node.getCreatedTime|date("d/m/Y")}}

Get term name of reference field in node

In following example field_company_name is a term rerence field in a content type so need to render that reference term name at…

23 April

Load taxonomy detail by term id in Drupal 10

Published On: Tue, 04/23/2024 - 13:29

If you have already term then you can get all other tern detail by given term ID

$term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load(TID);
$field_value = $term->FIELD_MACHINENAME->value;
$term_name= $term->name->value;

15 April

Cheat Sheet for using Twig Tweak in Drupal 10

Published On: Mon, 04/15/2024 - 17:52

1. **Render a View**:

- Use `drupal_view('view_name', 'display_id')` to embed a view.

- Replace `'view_name'` with the actual view name and `'display_id'` with the desired display (default is `'default'`).

- Example: `{{ drupal_view('who_s_new', 'block_1') }}.

2. **Get the Result of a View**:

- Retrieve the result of a view using `drupal_view_result('view_name', 'display_id')`.

- Parameters are the same as for rendering a view.

1 February

Functions file_create_url() not working in Drupal 10

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

 

\Drupal::service('file_url_generator')->generateAbsoluteString($uri);

 

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

Published On: Wed, 12/13/2023 - 21:49

Problem:

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
		$query->condition('status',1);
		$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

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…