Latest Articles
Our latest news updates and insightful blog posts, designed to empower you with the knowledge and strategies you need to succeed.
Found error "PHP EXTENSIONS Disabled" with Drupal 9 Installation
I got following error when installation Drupal 9
PHP EXTENSIONS
Disabled
Drupal requires you to enable the PHP extensions in the following list (see the system requirements page for more information):
- gd
So re…
Essential Modules in Drupal 8
Pathauto
The Pathauto module automatically generates URL/path aliases for various kinds of content (nodes, taxonomy terms, users)
Requirements Token CTools
8.x-1.8 Released 28 April 2020
ctools
ctools (Chaos Tool Suite (ctools))
Tools to make it easy for modules to let other modules
…
entityQuery not working return error in Drupal 10
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\QueryI…
Display Fields Value in Drupal commerce product template in Drupal 8
How can display fields value in product template of Drupal commerce in Drupal 8
First have to create template with name "commerce-product.html.twig"
Some examles of fields value which can be use in template to display output
Display user name of product author
{{ product_entity.getOwner.getUsername }}
Display user id of product author
{{ product_entity.getOwnerId }}
Display Product title
{{ product.title }}
Display product imag…
Disable cache for specific page routing in custom module in Drupal 8 or 9
Example is mentioned below where I have created a path (/mycustompath) so I want disable cache for this page then I have add following syntax with my code in the file (mymodule.routing.yml) or in your routing yml file
options: no_cache: 'TRUE'
Complete example as below
mymodule.form: path: '/mycustompath' defaults: _title: '' _form: '\Drupal\workassign\Form\MyTestForm' requirements: _permission: 'mymodule custom' options: no_cache: 'TRUE'…
Custom code to save value in error log in Drupal 9
To save values in the error log in Drupal 8, you can use the following custom code:
\Drupal::logger('my_module')->error('The error message: @variable', [ '@variable' => $value_to_save, ]);
In the code above, replace my_module
with the name of your module, and replace The error message
with the message you want to include in the log entry. You can include any number of placeholders in the message using the…
Custom code to disable or hide Node Attribute or Tabs in Drupal 8 or 9
When you create or edit a node there is some default option or attribute in Node Form so we can disable or hide through custom code by using following code in our custom module.
In my example trying to to through folrm_alter hook. Following code using hide URL Alia…
Custom code to add meta tag in Drupal 7
In your theme's template.php file, you could add something like **/
/** * Implements hook_preprocess_html */ function THEME_NAME_preprocess_html(&$vars) { if (current_path() == 'my/custom/path') { $description = array( '#type' => 'html_tag', '#tag' => 'meta', '#attributes' => array( 'name' => 'description', 'content' => 'here all description goes', ) ); drupal_add_html_head($description, 'description'); } }
Custom code on comment publish in Drupal 8
Custom code on comment publish in Drupal 8
If you want to add your custom code on published of comment then we can use hook"hook_comment_update"
"$comment->isPublished()" will check comment in published
For example you want to send mail when comment published or unpublished so you can follow these step
Open your .module file and add the following code, for example your module name is "mymodule" then
function mymodule_comment_update($comment) {…
Custom code if else condition in twig template drupal 8
In Drupal 8, you can use the {% if %}
statement to create if-else conditions in Twig templates. Here's an example:
{% if condition %} // Code to execute if the condition is true. {% else %} // Code to execute if the condition is false. {% endif %}
Replace "condition" with your desired condition to evaluate. You can use logical operators such as and
, or
, and not
to create more complex conditions.
Here's an example o…
Crreate user programatically in Drupal 8
Using following step and method to create user programatically
Must be use this line in above the code
use Drupal\user\Entity\User;
I have added two extra fields in user account that is mentioned below.
Phone - This is text type field. field_phone (Machine name)
Subscribe - This is multiple select type field has machine name as field_subscribe. Following options in
…
Colorbox image gallery not working on Mobile in Drupal
Step 1 - Go to configuration
Step 2 - Open Colorbox settings
Step 3 - Click on Advance setting
There is an option of Mobile detection if its "On" now it should be "Off"
Now clear cache I hope its work now.
There is setting screenshot image
…