Latest Drupal related questions

Score: 0
SlowCheetah avatar
How do I get the values of multiple fields?
us flag

I'm using Drupal 9 and created a module for a custom schema.

Is there a way to simply get all the values for entity fields?
Is it efficient to access each value one by one?

Score: 0
Best way to handle products with hundreds of different properties
au flag

I've started building a large Drupal Commerce shop for my customer. The customer has about 30000 products: clothes, electronics, decor, candies, etc. That means that in the shop there might be hundreds of different properties along all products. The products will be imported from manufacturers product feeds.

The properties are, for example:

  • Description
  • Country of origin
  • Materials
  • Product care ins ...
Score: -1
Best way of entering an internal link
ng flag

How can I enter an internal link that works for different path lengths and keeps working when I upload my site to the live server?

Say I have a page here http://localhost/site1/web/page1 and I want to create a block in the footer that has a link to this page.

If I use a relative link (e.g. page1) It will work when I'm on this page ...
http://localhost/site1/web/
But it won't if I'm on a multi segment p ...

Score: -1
Sia Seeya avatar
Drush using wrong PHP binary/config
at flag

Using D9 with Drush 10. MacOS/MAMP Pro.

Drush 10 is installed locally using composer and is starting fine and finding the database. sqlc works fine. (I have other Drupal sites that are working just fine with their composer drush, though they are Drupal 8)

The problem seems to be the php binary/config drush is using. In drush status I see:

PHP binary: /usr/bin/php

PHP config: /etc/php.ini

The PH ...

Score: 2
How do I get the names of the tables where field data is stored?
cn flag

In Drupal 7, one was able to retrieve the physical names of the database tables using some code like the following, it was pretty simple.

$field_definitions = field_info_fields();
foreach ($field_definitions as $field => $definition) {
  $current_storage = $definition['storage']['details']['sql'][FIELD_LOAD_CURRENT];
  $current_table = key($current_storage);
  $revision_storage = $definition['stor ...
Score: 0
Custom field type properties populated by fetched data
kr flag

I have a custom field type, org_person, with an autocomplete set up on it to search our endpoint of "people". It saves something like John Smith (12345) to the value property ($properties['value']).

The endpoint looks something like this:

[{id, name, title, ...}, {id, name, title, ...},...]

My goal is to, on entity save (and cron), query my endpoint and save the 30+ properties to the database.

I need to ...

Score: -2
commonpike avatar
How to reload a (custom) modules dependencies
in flag

In Drupal9 , if a module has dependencies, as in

my_master_module.info.yml

dependencies:
  - dependency1:dependency1
  - dependency2:dependency2

you cant disable/uninstall any of these dependencies using the UI - the checkbox to do that is disabled.

However, if a (custom) modules dependencies have updated, the dependant module does not automatically get enabled. You can also not enable it using the ...

Score: 1
Drupal 8 Theme suggestions for form children elements
ve flag

What is the best way to define template name suggestions for children elements of form in drupal 8?

In myTheme.theme I can define hook like this:

function myTheme_theme_suggestions_alter(array &$suggestions, array $variables, $hook) {
  if ($hook == 'form' & !empty($variables['element']['#id'])) {
   $suggestions[] = 'form__' . str_replace('-', '_', $variables['element']  ['#id']);
  }
}
 ...
Score: 2
kniro avatar
How do I return an empty build array and log an error?
pe flag

I am using the following code for a block.

class WeatherBlock extends BlockBase implements ContainerFactoryPluginInterface {
  
  // Dependency injection code
  
  public function getCity() {
    $ip = '193.62.157.66';
    try {
      $response_ip = $this->httpClient->get('http://ip-api.com/json/' . $ip);
      $response_data_ip = $response_ip->getBody();
      $data_ip = json_decode($resp ...
Score: 0
Deploying drupal 9 on a remote server
ng flag

I've built my website on my local PC and I'm ready to go live and move it to the remote server.

I've bought a shared hosting package (so I can't run scripts etc, but I can copy the files over and export and import the database using phpmyadmin).

I couldn't for the life of me find a deployment guide for drupal 9, so to get things going, I tried something similar to what I've done for drupal 7 and hav ...

Score: 1
Wrong user with currentUser() on prod
kn flag

I'm getting the name of my user that I load from the profile. It's works fine on my local, but on my prod, the firstname displayed is showing the name from the previous user. How do I prevent that ? This is how I get my data.

This is where I don't understand, I'm loading data by current user, but the user isn't the good one...

I have my "new" firstname only after clearing my website cache with drush ...

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.