Latest Drupal related questions

Score: 1
How accurate is the field list for estimating where fields are used?
id flag

I am trying to locate all places where a particular field is used. I am trying to see especially which all Views have required the field.

I was planning to do a manual search using editor Find and grep. Then I came to know about the field list option under Reports - /admin/reports/fields

It showed that the field is not being used by an views.

How accurate is this report? Can it be trusted blindly or d ...

Score: 1
Shakil Ahmad avatar
Generate same Path aliases for multi languages
ar flag

I have a content type Products. A pattern is defined via the Pathauto module for product CT. but my issue is that when I translate an entry/node it generates a translated path alias for Urdu in Roman-English(Urdu in English alphabet) But the spellings of that path are meaningless. When I uncheck "Transliterate prior to creating alias" It generates the aliases in pure Urdu which is unacceptable in my  ...

Score: 0
ashique avatar
How to inject/append child element to a radios element and give it an AJAX callback?
cn flag

How can I add independent child element to a radios element in a form? The radio elements are created by the following code.

$form['orderinfo']['billshipaddresses']['billingaddresses'] = [
  '#type' => 'radios',
  '#title' => 'Billing Address',
  '#options' => $formaddressesOptions,
  '#default_value' => '',
  '#ajax' => [
    'callback' => '::buildShipBillAddresses',
    'wrapper'  ...
Score: 0
pglatz avatar
How can I add markup for hyphenation to taxonomy term titles?
in flag

I'm displaying a list of taxonomy terms in a narrow column. Some of the names are too wide to fit and wrap. I thought perhaps inserting a <wbr> in the name would solve this, but the tag is just printed out as a literal. Is there a way to use rich text in taxonomy term names?

Score: 0
How to render a media field as responsive image?
cn flag

I'm trying to render a media field as a responsive image in a custom twig template.

My naive approach looks like this:

{% include 'responsive-image.html.twig' with {
  "sources": content.field_media,
} %}

which simply yields a series of errors like this:

"0" is an invalid render array key in Drupal\Core\Render\Element::children() (line 97 of core/lib/Drupal/Core/Render/Element.php). 

Presumably one of  ...

Score: 0
Yaroslav avatar
How to use methods from entity class if it doesn't have such service?
ng flag

I'm writing an EventSubscriber for the config entity of the domain module. My goal is to insert some data in its config on preSave event (it becomes from the patch for D9).

Here is my code from ConfigEventSubscriber class of my custom module:


namespace Drupal\custom_module\EventSubscriber;

use Drupal\Core\Config\ConfigCrudEvent;
use Drupal\Core\Config\ConfigEvents;
use Drupal\domain\Entity\Domain;
u ...
Score: 0
RominRonin avatar
Query the database for the value of a ckeditor field
in flag

So I want to QUERY the database for the contents of a field, the trouble is the field is a ckeditor field, so how do I write the condition correctly?

Normally it would be something like this:

$query = \Drupal::entityTypeManager()->getStorage('node')->getQuery();
$query->condition('field_ckeditor_field', $value_to_match); (edited) 

But for CKEditor fields there is a _value and _format column in t ...

Score: 1
Programmatically update field config (not storage)
ru flag

SOLVED, both methods below work perfectly fine, it was just a typo.

I need to programmatically update a field's config in hook_update. I need to do this on multiple projects, so I can't use the normal way with field UI and config sync. I've found documentation how to update the field storage and DB schema (1, 2), but no documentation how to update a field config only, so I assumed I can go along with co ...

Score: 0
yuuuu avatar
Delaying a Rules action until previous actions are complete
ao flag

I'm making an HTTP request in an action which obviously takes some time. I want to use the response of that request in another action, but every time I get an error since the request hasn't completed yet so the response variable is empty.

Specifically, I will save the json response from the first action and then pass it to a feed.

I'm using Drupal 8.

I've tried searching every form of words I can imagi ...

Score: 6
Akansha avatar
What method should I use instead of Drupal\Core\Entity\Query\Sql\Query::addExpression()?
my flag

I am using Entity Query to select nodes of two different types. The fetching seems to be working, but I to sort the returned values. Both the content types have different date fields. I know I could do this with $query->addExpression('COALESCE( field_date_1, field_date_2)', 'Date'); $query->sort('Date', 'DESC'); but addExpression() isn't an existing method, and the code throws this exception ...

Score: 0
How do I unset an entity reference using JSON:API?
cn flag

I can't figure out how to unset an entity reference (remove a reference to a term from a node) when editing content via JSON:API.

JSON to create a new node:

  const myNodeToPost = {
    data: {
      type: 'my_node_type',
      attributes: {
        body: {
          value: `${bodyText}`,
          format: 'basic_html',
        },
      },
      relationships: {
        refTerm: {
          data: {
   ...
Score: 0
SomebodySysop avatar
How to use hook_block_access() with custom block created in UI
gb flag

I have a custom block created using Drupal 9 Custom block library. I want to use hook_block_access() to control access to it, but, as it is a custom block, it does not have a block machine name. The only ID I can find (using Devel variables) is:

stdClass Object ( [CLASS] => Drupal\block_content\Entity\BlockContent [theme:protected] => [values:protected] => Array
( [id] => Array ( [x-d ...

Score: -2
Charly avatar
I cannot call a function in another JavaScript file
bi flag

I have two JavaScript files on my custom theme. One file has functions that need to be used on the other file. What I have below doesn't work. This is the error I get.

Uncaught ReferenceError: test is not defined.

jQuery will be used on both files.

file1.js

/**
 * @file
 * UI behaviors
 */

(function ($, Drupal) {

 'use strict';

  $(document).ready(function () {
    function test(){
     console.log ...
Score: 2
Kevin avatar
Update FieldStorageConfig for a field in an update hook properly?
in flag

I need to update the allowed values option on an list_integer field. For reasons at the moment, I can't just update and export the configuration and import it on production until we implement config_ignore. I also do not want to edit several block types to update a few field(s) coming up across several environments - so if I can script it and save time that is what I want to do.

In an update hook ...

Score: 1
STF avatar
Cloudflare cache everything
ch flag
STF

we have a Drupal 8 with Cloudflare cache rule. By default we have always GBP currency, then we developed a module that allow users change their currency with a footer dropdown and saves it on the user session.

Without Cloudflare cache rule, the webpage works correctly. The problem is if the rule is active, the first visit to the web is cached with the default currency, then if someone try to chan ...

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.