logo

Blog

31 January

Theming drupal commerce product page in Drupal 10

Published On: Fri, 01/31/2025 - 18:47

Theming a Drupal Commerce product page involves customizing the Twig templates, CSS, and possibly preprocess functions to control the look and feel of the product display. Here’s a structured approach:

Identify the Template to Override

Drupal uses Twig templates to render product pages. The most relevant template for product pages is:

commerce-product--[product-type].html.twig 

If your product type is "t-shirt", the template would be:

commerce-product--…

29 January

To install a module in Drupal 10 using Composer

Published On: Wed, 01/29/2025 - 15:33

Open a terminal and go to the root directory of your Drupal project.

cd /path/to/your/drupal-project

Use the following Composer command to download the module:

composer require drupal/module_name

Replace module_name with the actual machine name of the module. For example, to install the Pathauto module:

composer require drupal/pathauto

This will download the module and place it inside the web/modules/contrib/ directory.

After…

23 January

Twig Template Naming in Drupal 10 Themes

Published On: Thu, 01/23/2025 - 14:14

Twig templates are files with the .html.twig extension used to define the HTML structure and layout of various components in Drupal. These templates allow developers to customize the look and feel of pages, blocks, nodes, and other elements.

Drupal uses a hierarchical template naming system, making it possible to override templates for specific components, entities, or conditions. By naming templates according to conventions, you can ensure they are applied to the correct contexts.…

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.