Latest Drupal related questions

Score: 1
How can I get Average of a comment field by node_id?
us flag

I have Comments here wherein user can rate a content.

I want to get the average rating per content, how do I efficiently get the average?

I have the following code to get the Average:

$cids = \Drupal::entityQuery('comment')
    ->condition('entity_id', $variables['row']->nid)
    ->condition('entity_type', 'node')
    ->condition('comment_type', 'content_rating')
    ->execute();

$comment ...
Score: 2
Mauricio avatar
Disable a field if another field is disabled
lb flag

I need to disable field A if field B is disabled too. Actually, my current field A has the following #states (altered using hook_alter_form) to disable it if field B or field C are empty:

/**
 * Implements hook_form_alter().
 */
function my_module_form_alter(&$form, $form_state, $form_id) {
 
  $form['field_a']['#states'] = [
    'disabled' => [
      [':input[name="field_b[0][value][date]"]' =&g ...
Score: 0
May  avatar
User error: "1" is an invalid render array key. How do I find where the error is coming from?
zw flag

I get this error on every page. How do I debug or find what is causing it?

I thought it might have been changes to a twig template, but I tried other themes, and still had the error.

I've disabled all custom modules.

I searched and found User error: "1" is an invalid render array key in Drupal\Core\Render\Element::children() Which suggests its custom theming related but I am using core theme with ...

Score: 0
TableSort with entity query aggregate
ai flag

I'm trying to implement a table sort for a custom Drupal 9.x entity type Packet which represents published medical literature articles which have batched together and assigned for review. Each Packet has entity references to PacketArticle entities, and each of those has entity references to one or more Review entities. A Review has a reviewer (entity reference to a User), when the review was posted ...

Score: 1
Why is the order/weight of blocks added to region not saved?
cn flag

I have used layout builder to manage display on the default display of a content type.I have not selected "overrides allowed" so that this is the global layout for this content type. I see the "You are editing the layout template for all {{MyType}} content items."

Within one of the sections I am adding 4 blocks to a single region then dragging them into the correct order. However the order or wei ...

Score: 0
hockey2112 avatar
Results from "end date" in date range excluded from Views results
tr flag

I have a view of Commerce orders, and I need to add an exposed filter to filter the orders by date range. I have added two exposed filters for Order: Placed. One filter is "greater than or equal to" for the start date, and the other filter is "less than or equal to" for the end date. I also have Date Popup module installed.

When I choose May 15, 2022 as my start date and May 16, 2022 as my end d ...

Score: 1
Is "event_subscriber" a reserved naming convention for services? Are there guidelines to follow?
cn flag

So I was working on a project today, and an event subscriber we had written the better part of a year ago was determined to no longer be firing. Here is the definition:

services:
  my_module.event_subscriber:
    class: Drupal\my_module\EventSubscriber\XYZFeeds
    tags:
      - { name: event_subscriber }

I went through the normal debugging, and found that the event was not being added to the registry.  ...

Score: 0
Giuseppe avatar
How upload a file\image via json api?
br flag

I'm trying to upload a file or image on a D9 site via json api. The test is namely to upload the user picture on the user entity.

I've been following the documentation or read questions about, but I can't get it working.

The front-end is done with Next.js.

One the test done is the following:

The front-end next calls the next.js api server:

const filename = selectedFile.name;
const fr = new FileReader() ...
Score: 0
Anil Thapa avatar
Unformatted Views mutliple taxonomy terms
cn flag

I apologize if it's an obvious question and I'm fairly new to twig and drupal. I'm trying to get the all the taxonomy term selected on the field field_delivered_on_behalf_of in views-unformatted twig file. It just gets the first term but doesn't get the other terms.

{{ row.content['#row']._entity.field_delivered_on_behalf_of.entity.name.value }} 

I am thinking of loop as well but just couldn't get my hea ...

Score: 0
druplash avatar
Run into issues with Drush after updating from 8.9.20 to 9.3.13
jp flag

I upgraded from 8.9.20 to 9.3.13 and i did an update.php after this. I do get an error:

MISSING UPDATES FOR: VIEWS The installed version of the Views module is too old to update. Update to a version prior to 9.0.0 first (missing updates: views_post_update_remove_core_key).

If i try to update the databse with drush updatedb i get an error too:

In BootstrapHook.php line 36: Bootstrap failed. Run your com ...

Score: 1
Access permissions with the Entity Print module
in flag

I installed the Entity Print on my site. It works perfectly when used from the administrator user, but it doesn't work with anonymous users.

It gives the following error.

Access denied on the url /entityprint/pdf/node/nid

I tracked the error and found that is was caused by this code.

// Check if the user is allowed to view all bundles of the entity type.
$access_result = AccessResult::allowedIfHasPermi ...
Score: 2
Matt avatar
Use a different twig media template if it is being rendered inside a WYIWYG
cn flag

I have a twig template for a media entity that I wish to be able to embed into a WYIWYG. I am able to, however the entity has issues rendering when inside the ckeditor that aren't present when rendered on an actual page. I want to either use a different template or use some variable that detects whether the media is in an edit mode.

Is there a twig variable like {{ inEditor }} or is there a templ ...

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.