Latest Drupal related questions

Score: 2
Trudog avatar
How do I access current_page value in views twig template?
ru flag

In views-view.html.twig, I'm trying pager['#views_plugin'].current_page, but don't get any value.

enter image description here

Score: -2
How to enqueue CSS to administrator side via module
cn flag

I have a custom Drupal module and I would like to enqueue its CSS to the administrator side. I've tried to add it to the .info.yml file.

css:
  theme:
    admin-styles.css: {}

I also implemented hook_page_attachments() in the module as described in Custom module for adding CSS file in admin section.

function admin_css_page_attachments(array &$attachments) {
  $is_admin = \Drupal::service('router.ad ...
Score: 0
Joost avatar
Warning: Invalid argument supplied for foreach() ViewsData.php
jp flag

On my drupal 9 website I get a warning when running the Cache Clear Command. I get these two messages. I have no clue where to start with finding the problem. Hope someone understands these messages and can point me in te right direction.

Warning: Invalid argument supplied for foreach() in Drupal\views\ViewsData->getData() (line 239 of core/modules/views/src/ViewsData.php).
Drupal\views\ViewsDat ...
Score: 0
david avatar
Unable to programmatically render webform with CAPTCHA
ng flag

Our website has a custom route, with a controller rendering a custom Webform. This is required, as the form has some hidden fields to be pre-populated.

Now I would like to add the CAPTCHA module to the webform. When enabling the CAPTCHA for Drupal's default contact form and viewing it in incognito mode, it works nicely. The CAPTCHA shows up.

But when adding the CAPTCHA element to the custom form, it ...

Score: 0
bigboy avatar
How do I hide the tab menu link when a view is empty?
gu flag

I have a view with a menu tab link and an attachment, which displays rows of other nodes, depending on the contextual filter.

This view has a custom path(/node/%node/view-custom-path).

How do I show the menu link only when the following conditions are met?

  • The node has some taxonomy terms
  • The view attachment is empty

I have already set the needed term as filter criteria, but the link ignores it ...

Score: 0
How do I add a revisions tab to a custom content entity and list revisions?
in flag

I'm trying to achieve exactly what's described on How to add revisions tab to a custom content entity and list revisions?

I created my custom entity using Drush, and set it revisionable: Doin that, I got the entity class with all the entries mentioned at that post, except my_node.routing.yml, which hasn't been created by Drush.

I'm trying to create it manually but without success. The example descri ...

Score: 0
Md. Shafiq Hossain avatar
How do I pass a node field value as view argument to another entity reference field?
cn flag

The issue seems simple, but I can't get any documentation for it.

I have a content type with two drop-down fields: field_company which lists taxonomy terms and field_protocol which is referencing a view of entity reference type.

I want to pass the field_company value to field_protocol as view argument, so that when the company is selected, the protocol list is automatically filtered via AJAX. I did add  ...

Score: 2
Francesco Marchetti-Stasi avatar
AccessDeniedHttpException on a route with _access: TRUE
iq flag

In my custom module I have a few "publication" routes that do not need any kind of authentication. Months ago I learnt that I could achieve this with the following requirements in routing.yml:

my_module.myroute:
  [...]
  requirements:
    _access: 'TRUE'

This works on my existing routes.

Now I'm trying to add a new one that parses the Authorization HTTP header only for identification purposes: the pur ...

Score: 0
Why does clicking next to a new page just show the entirety of the previous page first?
us flag

I have three pages on a webform. When I click 'next' page 2 shows the entirety of page 1. The user has to scroll through everything to get to page 2. The same thing if I want them to skip from page 1 - 3 based on one conditional on page 1.

Drupal 7 didn't have all the problems I'm having on Drupal 9 webforms... what happened?

Score: 0
quantumized avatar
How to filter idlist in command line when importing data via migration
ng flag

I know I'm really missing something here. I have a custom migration source plugin that requires a query() to be returned.

If I pass an --idlist=123 parameter with the import this query still runs on all of the nodes as there is no way to limit it dynamically. What am I missing?

The migration is supposed to query the legacy D7 db for content types (event) and then I need to update each result's fi ...

Score: 0
emma avatar
Combine Aggregation with Pivot Table in Drupal Views
ro flag

I have some views that use pivot tables. Their purpose is to display an attribute (for example, the gender) and a year value (for example, the birth year), using a third field named ID. The gender is used as pivot row and the birth year as pivot column. ID has the Aggregation type "Count". Additionally, we have a Total column for the row aggregate (number of values in Pivot settings) that counts how many  ...

Score: 0
Drazen avatar
hook_theme_suggestions_image_alter() not returning ['data-responsive-image-style']
ru flag

Perhaps I have similar issue to this Drupal 9.2 template_preprocess_image hook not working.

When I put this code in myTheme.theme

function HOOK_theme_suggestions_image_alter(array &$suggestions, array $variables)
{
 $responsive_style = $variables['attributes']['data-responsive-image-style'];
 $suggestions[] = 'image__'.$responsive_style;
}

The hook works good on inline images with this module  ...

Score: 0
ostry.sn avatar
Reuse $view->result after getting field values row by row
br flag

Inside a hook_views_pre_render(ViewExecutable $view): When I try to get and use field values from $view->result, I could no more use the $view->result just after and the execution is interrupted with no explicit errors displayed. For example:

function custom_divers_views_pre_render(ViewExecutable $view) {
  if ($view->id() == 'localisation_front' && $view->current_display == 'blo ...
Score: 1
How do I remove the "Save draft" button from every page of a multi-step form?
cn flag

I have a multi-step webform and I want to add a save draft button however it needs to be added only to the last preview page and not all step pages.

I have used settings within submission to activate saving draft however the button appears on each page. Any way to hide, without changing code but just through configuration/settings?

Score: 0
ProGrammar avatar
EntitySubqueue save() only working with die() following it
ca flag

I am trying to add an item to a sub-queue automatically on save. And for some reason, it only works if I include die() afterwards.

This adds the new node to the queue

function custom_module_entity_insert(EntityInterface $entity) {
  ...
  $subqueue = EntitySubqueue::load($entityqueue_id);
  $subqueue->addItem($entity)->save();
  die();
}

This does NOT add the new node to the queue

function  ...
Score: 3
Schema information for module is missing - how to fix?
in flag

I tried to install the Scheduler module but it did not install properly because we somehow did not have code for another custom module that the database thinks was installed. I got the code for the missing module.

My scheduler module is completely borked, as is my database. I cannot uninstall the module because there is a missing field in the database.

Drupal\Core\Database\DatabaseExceptionWrapp ...

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.