Latest Drupal related questions

Score: 1
Is it possible to use a subquery in an entity query?
ai flag

How can I add a condition to a Drupal 9 entity query using another entity query on a different entity type?

I'll illustrate the question by describing one specific use case, though I don't think it would be difficult to come up with any number of plausible use cases.

The application for this use case tracks articles in published medical literature. An article is represented by a custom entity type w ...

Score: 0
Berry Dingle avatar
Throw error for required field in hook_form_alter?
cn flag

I have a node type that can be created by authenticated users. In the node create form, I added a terms-of-service checkbox via a form hook like so:

function themename_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'node_nodetype_form') {
    $form['field_tos_accept'] = array(
      '#type' => 'checkbox',
      '#title' => t('I agree to the terms of service.'),
      ' ...
Score: 1
How to query on last delta?
ai flag

The documentation for QueryInterface::condition explains how to narrow a condition to a specific delta of the field being queried. Is there a way to tell the interface to look at the value for the last delta of the field? I tried providing -1 for the delta, as this method is used by many programming languages for access to array elements counting from the end, but that only resulted in empty resul ...

Score: 0
Kevin avatar
Testing an internal Drupal API that requires POST
in flag

I want to add a test around an internal API in Drupal 8 that only accepts a POST payload and fires off some services. I am getting the following:

"curl error 3"

From Guzzle when trying:

$this->client->post('/path/to/api/123', ...opts

What would the base uri be under a Kernel test? Does this really need to be a Functional test?

Score: 2
Jaypan avatar
How do I create multilingual user path aliases?
de flag

I'm setting up a multilingual site, and I need the user path aliases to be multilingual.

Users are set up as translatable: User Translation Configuration

Language Detection: URL (path prefix)

  • English: /en
  • Japanese: No prefix

Pathauto patterns:

  • English: /en/users/[user:name]
  • Japanese: '/users/[user:name]

Pathauto Patterns

Example:

  • Username: Admin

Expected paths:

  • English: /en/users/admin
  • Japanese: /users/admin

Actual:

  • English: /en/user/1
Score: 0
What's the best way to migrate from manual upgrades to composer updates?
cn flag

I have an 8.9.19 installation that I would like to move over to use composer.

What's the best way to migrate the installation to use composer upgrades? Manual installations are becoming a real pain.

Score: 0
Jeirod avatar
How to create similar multiple forms using a button?
cn flag

I am using Drupal 9. I am creating a module that has a form with a button that will re-create another form similar to the first one.

These is my code.

public function buildForm(array $form, FormStateInterface $form_state) {
  $database = \Drupal::database();
  $result = $database->select('user_details', 'u')
    ->fields('u', ['uid']);
  $row = $result->execute()->fetchAll();
  $rowCount = c ...
Score: 0
madhukar avatar
Is there any way to add JS to form only when loaded using ajax-api in modal?
my flag

I have one page on which there is a button. On click of that button I am opening a webform in modal popup (Ajax dialog). What I need is to add a GA script to the form. I have tried using hook_preprocess_page and hook_form_alter to attach the script but none of these 2 works. However script gets attached to form if opened directly with URL.

   /**
 * @param $form
 * @param FormStateInterface $form_s ...
Score: 0
Some image styles not generating while other are
cn flag

I'm seeing a strange issue where some of our image styles seem to be broken while others work fine. The broken ones are showing the typical signs of the source image existing while the image style url used on the page is broken. I can't seem to find any consistencies -- similar effects are used on working and broken styles, and some broken ones are defaults (thumbnail) while others are customized. Quite ...

Score: 0
drupalhorn avatar
Auto create a feed when a node is added
ro flag

I am looking for a way to automatically add a feed (of a specific feed type), whenever a node is added (for a specific content type) using the node fields to auto-create the feed.

I have searched this site and globally; the closest solution I could find is the one described in Programmatically create and trigger feeds importer, for Drupal 7, although I cannot see why a template should be needed.

 ...

Score: 1
Kojo avatar
How do I override /libraries/ckeditor-wordcount-plugin/lang/some.js?
de flag

I'm using ckwordcount module which basically adds nice max length and counter features to text Fields, and relies on WordCount Plugin for CKEditor Editor.

Most of the translations in the plugin lang directory are incomplete, resulting in messy undefined strings displayed where we'd expect a clear message for end users...

Just to make sure this was the plugin translation source I edited the origin ...

Score: 1
albertski avatar
Can't change PHP version during Drush update database command
cn flag

My server currently is using PHP 7.1 but I need to run PHP 7.4 during my drush commands on one of my sites. The following works for almost all commands:

/path/to/my/php74 ../vendor/bin/drush cr
/path/to/my/php74 ../vendor/bin/drush cim -y

But when I run the update database command I get an error:

/path/to/my/php74 ../vendor/bin/drush updb -y

or:

export DRUSH_PHP=/path/to/my/php74 && /pa ...
Score: 0
List all the nodes with the same menu parent ID
pt flag

I have the following menu in my system.

screenshot

The parent menu-link connects to a node whose ID is 58. All the sub menu-links have a parent ID equal to 58.

I need to find the main and the sub-menus using 58, but I have been unsuccessful at locating the a table that contains that information.

How can I list the nodes that share a particular menu ID?

Score: 1
Hasina Njaratin avatar
Register form block into modal
de flag

I want to display the register form in a modal. For that, I created a custom plugin block which returns the rendering of the form register.

/**
 * {@inheritdoc}
 */
public function build() {
   $entity = \Drupal::entityTypeManager()->getStorage('user')->create(array());
   $formObject = \Drupal::entityTypeManager()
     ->getFormObject('user', 'register')
     ->setEntity($entity);

    ...
Score: 0
fallenturtle avatar
How do I get the entity ID from a view row and pass it along to the item list template?
au flag

I have a view which returns rows of entities. Each entity has several multi-value fields.

The structure is kinda like this:

  • Field 1:

    • Item A
    • Item B
    • Item C
    • ...
    • Item H
  • Field 2:

    • Item A
    • Item B
    • Item C

Field 2 holds values that are related to Field 1 Item B. When displaying Field 1 in the view results I'd like to be able to display them like:

Field 1: Item A, Item B (Field 2 Item A, Field 2 Item B),  ...

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.