Latest Drupal related questions

Score: 2
Siva avatar
Feeds Documentation for importing data programatically
us flag

Team,

I need a help.

I was surfing internet, but couldn't get a luck to get a working example/documentation to import data programmatically and store into our custom tables.

I'm using Drupal 9 version and feeds module, and for importing data related to users, content type, feeds modules help me a lot. But we have some custom tables as well, and stuck here to import. I have followed below link, but have ...

Score: 0
Hershel avatar
How can I Speed up Cache calls?
cn flag

I have a site with a few complicated forms. They require a lot of CPU time to calculate, so I am caching the $form array in order to be able to deliver the form quickly to the user. To do this, I am using an abstract class based on FormBase. Here is the code for this class:

abstract class PM_FormBase extends FormBase {
  public function buildForm(array $form, FormStateInterface $form_state) {
    $ ...
Score: 1
elizoliva avatar
using hook_form_alter() to change year range of datetime select widget, with deltas for multi-value fields
kz flag

I have multiple date fields on a node form for which I am using the select widget. The year select list has a range of years that is far too wide for our purposes (1900-present), so we want to limit it. I am able to accomplish this with hook_form_alter, however the fields that are multi-value to not reflect this change when they are loaded with ajax. Here is my current code which gets the first deltas:

Score: -3
Patoshi パトシ avatar
Best practice to upgrade drupal 9.4 to 9.5? Composer or Drush method?
kr flag

I can run this command to upgrade drupal 9.4 to 9.5, but I can also do it in drush. Which method is better and why?

composer require drupal/core-recommended:9.5.0 drupal/core-composer-scaffold:9.5.0 drupal/core-project-message:9.5.0 --update-with-all-dependencies

Score: -4
Why can't I use video_embed_html5 on Drupal 10?
cn flag

I'm trying to get past the video_embed_html5 error message while going to Drupal 10.0.1....it says it isn't supported in 10.0.1....does anyone know a workaround for this...

https://www.drupal.org/project/video_embed_html5

Score: 1
Robert avatar
How to use groupBy on query based on the search API views?
tg flag

My search api query returns a list of articles with its nid and field category. I would like to group by category. I mean 1 article by category. Is there a way to accomplish this? I tried via the _views_query_alter but it looks that SearchApiQuery $query has not the function groupBy.

Ex:

HOOK_views_query_alter(\Drupal\views\ViewExecutable $view, \Drupal\views\Plugin\views\query\QueryPluginBase $query ...
Score: 0
Manav Chauhan avatar
How can I add a button to every row of custom column?
np flag

I have created a custom column in the content listing section using hook_views_data(). I want to add a button to the every row of that custom column. Can anyone help me with this issue?

function sortd_views_data() {
  $data['node_field_data']['SortdAction'] = [
    'title' => t('Sortd Action'),
    'help' => t('Manual Sync/Unsync articles.'),
    'field' => [
      'handler' => 'views_ ...
Score: 1
Alex avatar
Is it possible to use OR condition in search_api_index view for exposed filters like "Fulltext search" or "Combine fields filter"
in flag

I have created search_api_index view.

And I want to add filter criteria like on screenshot. enter image description here

or

enter image description here

I choose OR condition, but the AND condition still works. It seems that OR condition is not applied. Is it possible to implement such behavior?

Expected result should looks like on the screenshot with OR condition enter image description here

Score: 1
Andrew Louis avatar
loadByProperties with multiple fields
ru flag

I want to find a node with some values in two fields. To do that, I use loadByProperties in this way:

$nodes = \Drupal::entityTypeManager()  
  ->getStorage('node')
  ->loadByProperties([
    'field_surname' => 'Surname', 
    'field_name' => 'Name',
  ]); 

This does not work. I am sure that at least one node with such values in these fields exists. This code is used in the .module file. W ...

Score: 1
Matt avatar
Sort nodes by weight of taxonomy term attached to field
cn flag

In a query for nodes I'm trying to sort the nodes by the weight of a taxonomy term attached to one of the node fields.

Here is how my query is built

    $node_storage = \Drupal::entityTypeManager()
      ->getStorage('node');
    $my_query = $node_storage
      ->getQuery()
      ->accessCheck(FALSE)
      ->condition('type', 'my_content_type')
      ->condition('status', NodeInterface: ...
Score: 1
Oleh Bardiuk avatar
How to pass a simple variable into form for twig? Not a form element
pr flag

I have a form that is working just fine. Now I need to make some logic in its twig file based on some field value. How do I pass that variable into twig? I tried a simple solution and it works, but I get errors.

$form['dates']['arrival'] = [
  '#type' => 'date',
  '#title' => $this->t('Arrival'),
  '#required' => TRUE,
  '#default_value' => $form_state->getValue(
    ['dates', 'ar ...
Score: 0
Chapabu avatar
Facet blocks in a dialog don't retain applied facets
us flag

Cross posting an issue I posted from Drupal.org in the hope that it gets a bit more visibility here.

I'm currently loading facet blocks via AJAX into an off canvas dialog provided by the core Dialog API. To achieve this, I have a controller set up that accepts a facet ID as a parameter, and then loads the block (I've attached the code at the end of this question as an example).

This works perfectly o ...

Score: 0
interaction between form element plugins and config entity plugin collections
by flag

I'm making a form element plugin which has compound elements, but which should return a single string value. This is the same idea as core's password confirm form element (https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21Element%21PasswordConfirm.php/10).

I've imitated what password confirm does: an #element_validate callback gets the value from the inner elements, and sets it as t ...

Score: -1
Free Radical avatar
Where is the look of the Search button in Bootsrap5 defined?
kz flag

I have a Drupal 9.5.1 website with Bootstrap5 2.0.6 as its base theme. The theme by default places a search form by means of a block named "Search" in the "Additional navigation region".

This block "Search" is provided by core, but how its looks seems to be determined by the theme. If I change the theme to Bartik, the same block by default appears in the "Sidebar first" region, but the button to press to ...

Score: 0
Commerce Event Subcriber
cn flag

I have created a custom event subscriber for Commerce, but when the event is triggered, somehow the Order number is increased by +1 and I get suddenly confirmation emails for 2 orders.

I'm not doing anything special when the event happens, just sending a test email.

  static function getSubscribedEvents() {
    $events['commerce_order.place.post_transition'] = ['orderCompleteHandler', -200];
    retur ...
Score: 1
Alex Niem avatar
How to get comment's field value in view
vi flag

I want to create rating of companies based on values of comments fields.

Companies rate table: enter image description here

Comment form example: enter image description here

Here's my Drupal settings:

Nodes (type "Company") with comments. Comments with additional fields (as taxonomy vocabularies): stability, support, performance. My vocabularies list: taxonomy vocab

For example, vocabulary "Performance" has terms: enter image description here

Also, I added additional field "points" (integer) in this  ...

Score: 0
LMatter avatar
Changing from CKEditor 4 to CKeditor 5 Textformat got lost
sy flag

Since I changed from 9.4.0 to 9.5.0 I tried to use the CKeditor 5 But when I wanted to modify the Text formats and editor full HTML, it didn't work. so I delete the full format HTML. But when I wanted to reainstall a full_html Text format, I got the answer that the field already existed. So I had to create a new Text format with a new machine name. But in that case the new textformat shows in a Textwind ...

Score: 1
user1414202 avatar
How can I return a templated response from an Exception Event subscriber?
ve flag

I'm currently using an Event Subscriber to catch exceptions and return a plain-text message response to the user (instead of the default white screen of death).

Is there a way to return a templated response (using the site's theme, similar to a Controller's response) from the event subscriber in Drupal 9/10?

Score: 0
duck avatar
Drush commands not defined - drush 11.4.0 drupal 9.5.1
in flag

This configuration is working properly on xampp local install (drush version)

Drupal version : 9.5.1 DB driver : mysql DB hostname : localhost DB port : 3306 Database : Connected Drupal bootstrap : Successful PHP binary : C:/xampp/php/php.exe PHP config : C:/xampp/php/php.ini PHP OS : WINNT PHP version : 7.4.27 Drush script : C:/xampp/htdo ...

Score: 0
gzwg avatar
Why fails the comparsion between two identical version numbers in this script?
cx flag

I try to compare in a Script two different version numbers of Drupal via drush status. The result should be printed out in a if-else. I made a minimal example:

# put paths in vars
WEBSITE_ROOT_LIVE=/PATH/TO/LIVE
WEBSITE_ROOT_TEST=/PATH/TO/DEV

# get the drupal version line from drupal status output
cd $WEBSITE_ROOT_TEST
test=$(drush status | grep "Drupal version")
cd $WEBSITE_ROOT_LIVE
live=$(drush status ...
Score: 0
Menno van den Heuvel avatar
Manually create an HtmlResponse for an entity view
cn flag

How do I manually create an HtmlResponse object that returns the full html for an entity view; identical to the html returned for the entity.{{whatever entity id}}.canonical route?

Context: I'm subscribing "kernel.request" to check for certain URL's that are supposed to bypass Drupal Path processing altogether. For some of these I'm returning a TrustedRedirectResponse, but others should show (not ...

Score: 0
Tomáš Bažant avatar
Shared sites/all/libraries/ directory is not recognized by contrib modules
de flag

I'm trying to put the colorbox javascript library to the shared sites/all/libraries directory but it is not recognized by the colorbox module. The same seems to go for the jquery.cycle library. I just copied the libraries directory from sites/nias.cz/libraries` to the shared one. The final example path is

sites/all/libraries/colorbox/jquery.colorbox.js
Score: 2
How to do dependency injection for ConstraintValidator?
cn flag

After upgrading to Drupal 10, running the coding standards check suggested that I could use DI in my validation constraints.

For example, this simple one:

<?php

declare(strict_types=1);

namespace Drupal\my_module\Plugin\Validation\Constraint;

use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;

/** ...
Score: 0
Patoshi パトシ avatar
How can I find out if all my contrib modules are compatible with the latest core version?
kr flag

I have quite a number of Drupal modules on my Drupal 9 website and I want to update my Drupal core to the latest, but I'm not sure if this would break the entire site if one of the modules isn't compatible with the latest core version.

I can go to each module page individually to check, but is there a quick command in the CLI to find out? drush pm-list doesn't really seem to help.

Score: 0
Jean Vieille avatar
How to prevent modal boxes for Drupal 7 edit forms
cn flag

I am very annoyed by the modal boxes showing up for most edit functions in Drupal. For example, when editing a php field code, only a few lines are displayed, I must copy the content in an other editor and back. How can we prevent this "smart" feature to get back to the old fashion editing?

Score: 1
techenzie avatar
Why is my translated content loaded on a 'raw' node address even when there is an alias given? (Multilingual Site)
lc flag

I have two languages (English and Spanish) in my Drupal site. The default language (English) content has already been created and now I need to translate the content (articles/pages/blocks) into Spanish for the respective entities. Let's say there is an About Us page which has an alias as '/about-us'. Now, when I go ahead and translate this to Spanish (enabling all the language modules and enabling conte ...

Score: 1
Matt Pugh avatar
How can I find all the nodes that use a hierarchical vocabulary taxonomy term and reference a child term but not its parent term
ps flag

I am using Drupal 7. I have a content type "Public Resource" that uses a hierarchical vocabulary called "Resource Topics" that has up to 3 levels (parent->child->child of child).

We have about 1000 Public Resources that are created. It has come to my attention that when our staff has been creating Public Resources nodes and choosing the "Resource Topics" terms if they choose a child they d ...

Score: 4
Martin Joergensen avatar
How can I dynamically switch between two databases for ALL queries?
cn flag

I need to copy some entities from one Drupal 9 database to different Drupal 9 database. I have searched and looked high and low, but none of the examples I have found work anywhere. I found no help on drupal.org, so I'm reaching out here.

Both databases are full Drupal 9 databases; they are almost identical, but some nodes and users are present in one, which I need to copy to the other.

In Drupal 7  ...

Score: 0
Ivan Leon Yam avatar
Where can i find the path/URL of a module after installing it?
ge flag

I just installed two modules on a Drupal 9 site: https://www.drupal.org/project/simple_forum and https://www.drupal.org/project/answers.

I want to get the URL where all posts/questions are listed and use it in a menu, but I cannot find where those are. The only thing I found is the URL for creating new posts and questions.

Score: 0
lee avatar
Hide/remove "Last" label/icon in views pager
cn flag
lee

I don't want my user to click the "Last" label on the views pager, but I can't find a way to remove this "Last" label even I leave the "Last page link text" field empty, I don't want to use the mini pager, so in the full pager, how can we remove the "Last" label/icon ? Thanks

The Stunning Power of Questions

Much of an executive’s workday is spent asking others for information—requesting status updates from a team leader, for example, or questioning a counterpart in a tense negotiation. Yet unlike professionals such as litigators, journalists, and doctors, who are taught how to ask questions as an essential part of their training, few executives think of questioning as a skill that can be honed—or consider how their own answers to questions could make conversations more productive.

That’s a missed opportunity. Questioning is a uniquely powerful tool for unlocking value in organizations: It spurs learning and the exchange of ideas, it fuels innovation and performance improvement, it builds rapport and trust among team members. And it can mitigate business risk by uncovering unforeseen pitfalls and hazards.

For some people, questioning comes easily. Their natural inquisitiveness, emotional intelligence, and ability to read people put the ideal question on the tip of their tongue. But most of us don’t ask enough questions, nor do we pose our inquiries in an optimal way.

The good news is that by asking questions, we naturally improve our emotional intelligence, which in turn makes us better questioners—a virtuous cycle. In this article, we draw on insights from behavioral science research to explore how the way we frame questions and choose to answer our counterparts can influence the outcome of conversations. We offer guidance for choosing the best type, tone, sequence, and framing of questions and for deciding what and how much information to share to reap the most benefit from our interactions, not just for ourselves but for our organizations.