Latest Drupal related questions

Score: 0
Quetzcodecoatl avatar
Unsuccessfully trying to get to the correct target_id
tw flag

So I've been programming a module that needs to show different pictures depending on the language code of the user (en vs. fa). For that I'm trying to get to the right target_ids. Debug($nodes) shows me the following:

        [field_picture_active] => Array
            (
                [x-default] => Array
                    (
                        [0] => Array
                         ...
Score: 1
user1015214 avatar
Commerce Migrate module not listed in migrations
st flag

I installed the Commerce Migrate module, and its submodules, commerce_migrate_commerce and csv_example. When I run drush migrate:status, I see the migrations for the csv_example listed but none of the commerce_migrate_commerce ones?

I likely will have to write my own migration anyways, but I was confuse at this discrepancy.

enter image description here

Score: 1
Giuseppe avatar
Is possible to add a field to content moderation's states?
br flag

I'm on D 9.4.x and using content moderation module.

Is possible to add a custom field to the states of the workflows\module?

E.g. add a boolean?

Score: -2
Frans avatar
Serialization of 'Closure' is not allowed in serialize()
bf flag

i am in the midst of fixing our website (which is built using Drupal version 7.67) that shows many errors after the PHP version is updated into PHP 8.0.

One of the errors that i am stuck now is this particular error

Exception: Serialization of 'Closure' is not allowed in serialize();

After i did some traces, it appears that this is happening when drupal_get_form or drupal_build_form is getting c ...

Score: 0
Node form field validations on change with AJAX
ke flag

I'd like to be able to trigger the validations for a field, including relevant entity constraints, on a change (or equivalent) event for the field using AJAX. But I cannot figure out how to make that happen. It looks like the validation code is being called, but validations are disabled in form state (limit_validation_errors is set to []). I can hack that but I assume it's doing that for a reason.

Score: 1
Shane avatar
How to obtain a node id and product type from the product variation id?
gu flag

I have a view in Drupal that has a field called Index product variation search: Item ID. Its description is "the item's internal (search API specific) ID".

Here is an example of what this field looks like: entity:commerce_product_variation/111:en

What is this number (111)--is it the product_variation id?

Basically, I am sending in this number through a POST API call (in javascript). I need to use t ...

Score: 1
Deej avatar
Canadian Tax Free
nl flag

I am trying to add Gift Cards to a Canadian site, and those cards are to be the only tax free item on the site - We're online so the customer could be in any province.

No matter what I try, I cannot make the product tax-free. I have created a new product type, and a new variation type, created a new product of that product type, with a variation of that variation type, and when I add it to the c ...

Score: 0
Giuseppe avatar
How configure webp with image optimize?
br flag

I'm on D9.4.x using ddev as local server.

The site have already configured Image optimize and Image magick There's a image optimize pipeline that is the default for all the image styles.

imagemagick configuration image optimize configuration

Now, I've been asked to convert all the sites's images into webp. I've tried alternatively webp and imageapi_optimize_webp but I can't get to neither of those to work.

I've add to the "lossless pipeline" the "Webp" pro ...

Score: -1
shibasaki_stack avatar
Unable to connect to database when launching a new Drupal site with Lando
zm flag

I tried to set up a new local drupal9 site using Lando, but it is unable to connect to the database and I am getting the following error.

Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2002] No such file or directory.

Checking the Lando logs shows the following.

PDOException: SQLSTATE[HY000] [2002] No such file or directory in /app/web/core/l ...
Score: 1
Andrew Morris avatar
How to separate Twig array via batch
mw flag

I'm trying to structure the output of a view into specific HTML for a carousel/slider I'm generating, basically I'm trying to turn a regular list of X people into groups, which I'm then dividing further for the purposes of structuring the HTML as I need

currently my rows variable contains X items (likely between 50-100)

  • I am trying to split that into pages of 12 items
  • Each page has 4 rows and 3  ...
Score: 1
adam_bear avatar
Class arguments not being passed
cn flag

Updating the emulsify_twig extension for D10, for some reason the class arguments aren't being passed... I'm extending Drupal\Core\Template\TwigExtension and using the same default arguments but for some reason it isn't picking up the arguments, resulting in: ArgumentCountError: Too few arguments to function Drupal\emulsify_twig\BemTwigExtension::__construct(), 0

This is the relevant code from the class ...

Score: 1
How can I display no results text in a template?
eg flag

I have added no results behaviour text to a view called Events which is a page. This template I am using has a twig called views-view--events--page_1.twig. I want to add the no results text to this twig template, but I can't find any way to do it. How can this be done?

Score: 4
Pedro avatar
How can you attach a file to a mail using Symfony mailer?
ml flag

I want to attach a file to a mail from an input file in my form. Here is how I build the mail :

$mailManager = \Drupal::service('plugin.manager.mail');
$params['title'] = 'title test';
$params['message'] = 'my message example';
$form_file = $form_state->getValue('my_input_file');
if (isset($form_file[0]) && !empty($form_file[0])) {
      $file = File::load($form_file[0]);
      $params[' ...
Score: 5
Jimmyb_1991 avatar
Add third party settings to a basefield definition
cn flag

Is there a way to add third party settings when defining a basefield for a custom Content Entity?

I am creating a new Entity type and want to keep the fields defined in code vs config as much as I can. I have an address field and a geofield field defined. I need to add third party settings to the geofield to allow it to geolocate from the Address field.

I was able to get the settings from the yaml co ...

Score: 0
Ivan Ginovski avatar
How to translate breadcrumbs block via drupal_block() in twig?
jp flag

I am trying to translate the breadcrumbs block in Drupal 9.3 via Twig Tweak I am loading the block in a twig like so:

{{ drupal_block('system_breadcrumb_block') }}

If I leave it like this, it only returns Home --> Page_name (In english) Even if it is another language selected (de). Is there some way to pass a language parameter to this function? Or somehow to indicate that it should be loading the  ...

Score: 0
user1015214 avatar
Cookie value causing a "Uncaught Error: Call to undefined function menu_get_object() " error
st flag

There are plenty of posts regarding this Drupal error, but my situation is quite odd indeed. Here's the background:

I was asked to investigate an ajax error popping up on a form which does an account lookup. The following is the consistent behavior I'm seeing:

  1. Log into site perfectly fine and navigate to any page without issue.
  2. Recreate error
  3. Now ALL pages on the site error out with the error Uncaug ...
Score: 1
liquidcms avatar
Why is ScrollTopCommand not working?
us flag

I have a node edit form which I submit via ajax and then opens a modal doing this:

  $form['actions']['submit'] = array_merge($form['actions']['submit'], [
    '#value' => t('Get quote'),
    '#ajax' => [
      'callback' => 'open_quote_modal',
      'event' => 'click',
    ]
  ]);
  $form['#attached']['library'][] = 'core/drupal.dialog.ajax';

This works fine. In my ajax call from this sub ...

Score: -1
Thony avatar
How do I compile code with globals in Typescript?
cm flag

Hi I'd like to use Typescript in my Drupal 9 Theme. I've setup compilation... but once I start declaring new behaviors like so:

(function ($: any, Drupal: any) {
  Drupal.behaviors.my_behavior = {
    attach: function (context: any, settings: any) {
    }
  };
})(jQuery, Drupal);

Ts compiler give me TS2304: Cannot find name 'jQuery'. and TS2304: Cannot find name 'Drupal'. while everything works fine i ...

Score: 0
Why can’t I install the module after uploading it?
US flag

I uploaded the Commerce Core module (8.x-2.32) from the /admin/modules/install tab. After uploading it, the modules list shows the module as disabled. I cannot select the checkbox shown for this module to install it.

Why cannot I select the module to install it?

Score: 0
Prestosaurus avatar
How to re-write exposed form multi-select query key identifiers?
ve flag

I'm wondering if there's a way to update the "identifiers" (not sure of the terminology) of a key from the URL when setting an exposed form field to multi-select?

The key pattern in the URL is key%5B0%5D=238.

Looking in the Request Stack $this->requestStack->getCurrentRequest(), these options are returned as an array:

key
  0 => 13
  1 => 238

I'm currently working in a custom class c ...

Score: 1
Rubix05 avatar
Storing PDF Subject Data in Media Entities
cn flag

I have pdf documents that I need to create as entities on our website. The pdfs were created with metadata, such as title and subject, that we want to have available in Drupal.

I am trying to save the subject metadata in a new field that I added to the Document media type.

I do not believe that pdf metadata is being stored in either the media object or the file object by default.

I have attempted to ho ...

Score: 1
mogio avatar
Migrate Module: How skip whole item (not value)
cn flag

I have a xml file that creates nodes via migrate.

I need to define the following:

Each job has a field "location". I have written a process plugin to process the value When the returned value is "null" ... skip the row (not just the field - skip the whole job item) I thought I do it right by using this yml structure / script

process:

  _job_location:
    - plugin: process_job_location
      source: src_ ...
Score: 0
Kait avatar
How can i add a class with 'html' tag(not with body) for specified pages (10 nodeID's)?
ye flag

How can i add a class with 'html' tag(not with body) for some specified pages (10 nodeID's) ? I tried with html preprocess, but didn't worked,

Score: -3
How to add an ajax throbber to my theme?
us flag

I created a new theme based on Classy.

base theme: classy
core_version_requirement: ^8 || ^9

regions:
  header: 'Header'
  content: 'Content'
  footer: 'Footer'

libraries-extend: {}

libraries:
  - my_theme/global

global:
  version: VERSION
  header: TRUE
  js:
    dist/js/app.js: { minified: true }
  dependencies:
    - core/jquery
    - core/drupal
    - core/ajax
    - core/drupalSettings
    - co ...
Score: 0
Jeff_dan13 avatar
How can I add a start and end date range in views exposed filter for Drupal 9 webform submission data?
bd flag

I have created a view which displays all the webform submission data, but when it comes to views exposed filter for the dates I'm unable to find a way to add a webform submitted date as a range, I did add the dates separately giving an offset value but this isn't working as a range. is there a way to get a single date as range?

Score: 0
Beakal avatar
Why does layout builder duplicate the body of a node after a full configuration import?
co flag

I used Layout builder for a site (Site A) using Drupal 9 and configured the Article content type to

  • Use Layout Builder and
  • Allow each content item to have its layout customized

This allowed me to customize each article node page whenever is needed. While this module is working as epxected in Site A, exporting and importing all the site configuration to a new Drupal site (Site B) creates the follow ...

Score: 0
SomebodySysop avatar
How do I specify ALL source node types in upgrade_d7_node_complete_book migration yaml
gb flag

Drupal migrate_plus creates a default migration yaml for migrating books: upgrade_d7_node_complete_book.yml

langcode: en
status: true
dependencies: {  }
id: upgrade_d7_node_complete_book
class: Drupal\node\Plugin\migrate\D7NodeTranslation
field_plugin_method: null
cck_plugin_method: null
migration_tags:
  - 'Drupal 7'
  - Content
migration_group: migrate_drupal_7
label: 'Node complete (Book page)'
 ...
Score: 1
mbomb007 avatar
Correct schema for an Entity Reference in config settings
nl flag

Background

I am creating a schema for a custom module's config settings, which are saved from a simple settings form. It has some basic fields, such as a checkbox for a Boolean value for hiding some data. However, it also has an entity reference field (e.g. hide_data_terms) that allows selecting taxonomy terms from a specific bundle data_terms. It will save the term IDs to the settings YAML.

Here's my ...

Score: 2
CWolf18 avatar
Why doesn't the entity access handler I wrote work when the entity is referenced?
ga flag

I have set a handler for the access of my entity but when I reference it in another entity, the access is not checked. I want the reference and the entity to have the same access check. Any idea ? The entity is a taxonomy term and I reference it in a basic node

The handler below, I return forbidden to test

/**
 * Defines the access control handler for the taxonomy term entity type.
 *
 * @see \Drupal\ ...
Score: 0
Deej avatar
How can I provide composer with a twig version that it's okay with, so I can roll back Drupal to a version that will work with PHP 7.4?
nl flag

I inherited a broken Drupal 9 site. Drush could not be made to work, so I deleted the vendor directory, renamed composer.lock and reinstalled. This has worked for me before on broken sites. Now I whitescreen when I log onto the site (which works well for anonymous users)

Because I still don't have drush, and I can't log in to the site, I can't flush the cache. Running mysite.com/update.php show ...

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.