Latest Drupal related questions

Score: 0
jacksparrow avatar
Update field without node save
ve flag

I am a beginner in Drupal, I would like to insert a value into a node field. But instead of a node->save() I want to avoid any presave hook and insert it directly using sql query. I have the entity_id to insert also in the field_NAME_value column, is this the node id? Or how do I get this? Or is there a way to do a node save without calling presave ? Thanks

Score: 0
Lambic avatar
Why aren't my rest responses being cached?
ph flag

I created a simple rest endpoint to test caching and I see the response updating. What is stopping it from being cached?

Here's the rest endpoint code:

<?php

namespace Drupal\nm_base_api\Plugin\rest\resource;

use Drupal\rest\ResourceResponse;
use Drupal\rest\Plugin\ResourceBase;
use Drupal\Core\Cache\CacheableMetaData;



/**
 * This is just an example.
 *
 * @RestResource(
 *   id = "test",
 *   ...
Score: 0
Disable javascript in selenium test? (WebDriverTestBase)
in flag

Background

A website I work on has a progress bar that gets an initial value from Drupal, and is then updated to the "correct" value with javascript.

I am writing a test with WebDriverTestBase that should assert both the initial value (before js kicks in) and the updated value (after js run).

Problem

Unfortunately, the test only gives me the html with the updated values. So I cannot assert that the or ...

Score: 1
Programmatically set exposed filter not possible when also using contextual filter
ru flag

I've got a view, that needs to set the default value for an exposed filter based on a user entity field. This basically works:

function MYMODULE_views_pre_build(\Drupal\views\ViewExecutable $view) {
  if ($view->current_display !== 'MY_VIEW_DISPLAY') {
    return;
  }
  $exposedFilterValues = $view->getExposedInput();
  if (!array_key_exists('MY_FIELD', $exposedFilterValues)) {
    $personali ...
Score: 0
Is there a way I can forward specific Webform Submission Results (from admin) to an email address I enter?
cn flag

I'm in the process of setting up a "system" where users can submit their Webforms with accompanying details/files and it gets logged into the Webform>Results>Submissions page. This all works great.

What I'm having an issue with, is taking specific submissions from the full list and forwarding those select few to a specific email address that I indicate (somehow). This email address will va ...

Score: -3
ponies avatar
Upgrade fails with InvalidArgumentException
me flag

After upgrading from Drupal 8.9 to Drupal 9.3, I get this fatal error when I run the database updates. The remaining updates aren't executed. It looks like the Multiversion Uninstall command needs to be run, but it's not installed.

system module - Update entity_revision_metadata_bc_cleanup

Failed: InvalidArgumentException: Drupal\multiversion\Entity\Storage\Sql\ContentEntityStorage does not imple ...

Score: 0
Toolbar overlap on shortcut pages
ph flag

The admin toolbar uses JavaScript to apply padding to the top of pages using Drupal.toolbar.views.toolbarVisualView.updateToolbarHeight().

Unfortunately, it seems this doesn't run properly when you visit a page in the shortcuts menu and the toolbar overlaps the page header.

toolbar overlapping

If you run that function in the console, the page fixes itself.

Is there a fix for this behavior? Can I inject this JavaScript  ...

Score: 1
Field Label Translation not working
cn flag

I have a Drupal 9 site. The default language is English, second language is German. I keep having problems with translations in the backend. Lots of field labels and other text shows up in English, even though the URL contains "/de/" (German).

Most simple use case:

  • The "simple page" has a field "teaser text". If I edit this field definition, there is a translation tab. I verified that the English langua ...
Score: 0
How do I get the bundle name by route?
us flag

I would like to pass variables to twig that depend on certain routes or node types (bundles) (a user page, a comment, a page or a custom content type). I used the name of the route (entity.comment.edit_form, entity.user.canonical) for that purpose.

Now I need to exclude some node types (i.e. I can't use just entity.node.canonical for all cases, I need to create a special condition for certain type ...

Score: 2
quantumized avatar
Is there a way to not include the {{ content }} variable in a node template and still have the node cache clear when the node is updated?
ng flag

We have nodes that have dozens of fields and have elected to not include the {{ content }} variable as it is tedious and looks messy having something like the following just to not print the fields. We're manually outputting each field as needed like {{ content.myfield }}.

The problem is that when the {{ content }} variable is not in a template then that node's cache does not get cleared when a user ...

Score: 2
miststudent2011 avatar
how to extend existing drush command class
fr flag

Can anyone please let me know how to extend existing drush command class.

I am writing a custom module which provides custom content entity and created a devel generate plugin similar to ContentDevelGenerate.

It is working as expected to generate dummy content from UI . I would like to create a drush command as well for the devel generator plugin. Similar to DevelGenerateCommands content method I would li ...

Score: 0
How can I inject services into my entity bundle class?
cn flag

I have an entity with a JSON field, and I do some complicated processing when the entity is saved.

Right now, I do this processing in hook_ENTITY_presave(), which calls a service I have created in a custom module.

However, since Drupal 9.3, we can create bundle classes to extend entities cleanly.

So I made one for my entity, and I wrote some new getters and setters so I can do $entity->getMyValue() ...

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.