Latest Drupal related questions

Score: 2
xpersonas avatar
Add an image to a vocabulary
cn flag

I need to add an image to a vocabulary, not the taxonomy terms. Essentially, I need to add a field to the "Edit Vocabulary" page.

Is there a way to do this?

Score: 1
Giuseppe avatar
How can I return a 404 error when the contextual filter value is provided in the URL, but the view returns no result?
br flag

I'm on building a rest view of nodes using Serializer as formatter. This view has a contextual filter on a plain-text field of that content type.

How can I return a 404 error when the contextual filter value is provided in the URL, but the view returns no result?

I've tried various validators, such as content, field, or basic validation, but none of them does what I'm looking for.

Score: 0
RuntimeException: Failed to start the session because headers have already been sent by
cn flag

New to Drupal, I just created a new custom module in Drupal 9 to see how it works I was trying to test with a minimal piece of code. I just enable this module and got this error, now I can't open anything and getting this error on every page nothing is happening even if I change anything in code. This is my custom module code.

check_hookcalls.info.yml

name: hook calls checking
description: module for test ...
Score: 1
BlondeSwan avatar
How are compiled CSS and JavaScript files handled with S3?
br flag

I have my Drupal site set up to upload public files into the S3 bucket but am having some strange behavior with different environments and different s3 buckets. I have 3 s3 buckets: one for our production environment, one for our staging environment, and one for my development environment. The Drupal configurations are set up to point to their respective s3 bucket based on environment.

There's be ...

Score: 0
Ats Miller avatar
Why does installing this module fails?
lk flag

I used composer create-project drupalcommerce/project-base commerce --stability dev, as suggested from Installation|Drupal Commerce Installation starts normally, but after I am asked for the database credentials, the installation fails with the following error. (The server document directory for https://pood2.veskimees.eu/ is /commerce/web.)

Error: Class "Drupal\shortcut\Entity\Shortcut" not found in co ...

Score: 1
How do I force the pager to update?
pl flag

I have a custom form built with the Form API. The general flow is:

  1. Build and display form
  2. Get user input
  3. Rebuild and form
    • query based on user input with added

      $query = $query
        ->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender')
        ->limit($values['items']);
      

This all works well for the first submission and for paging between submissions, but when a user enters a different value fo ...

Score: 1
DiDebru avatar
How to add language prefix to form action?
ng flag

We have a multi lingual site that default is "en".

Sometimes editors are creating content in another language like "de" and than translate it to "en".

My problem is that we use Layout builder visibility rules for blocks.

And the form action attribute that is rendered as example below.

Does not have a language prefix.

And therefore ends up in a 403 response for every content page that is not created ...

Score: 1
Baud avatar
How to hide a form element when a datetime widget is filled using #states
sa flag

The following code is working well to hide a button when a textfield is filled, but it is not working when a datetime widget is encoded:

$form['my_button'] = [
  '#type' => 'container',
  'submit' => [
    '#type' => 'submit',
    '#value' => t("Click on me"),
    '#submit' => ['submit_me']),
    '#states' => [
      'visible' => [
        ':input[data-drupal-selector=selector- ...
Score: 0
Values ​in a custom composite webform 6.0.4
cn flag

I need to create a custom composite with some fields in my form. There is also a date there. I have to compare the date field with another field.

I need an appropriate token to reference the date field in the custom composite. Can such a token be created at all?

I use webform 6.0.4 in drupal 9

Thank you in advance for your answer.

Score: 1
Return a Closure from a Factory
cn flag

I have services that depend on request information. I'm trying to create a Factory Factory which will have the Dependency Injection container returns a factory (an anonymous function) that will create the services I want. So basically somthing like this:

class FooFactoryFactory {
  public static function create(ContainerInterface $container): callable {
     return static function (Request $request) use ...
Score: 0
?page=n conficts with the Infinite Scroll Views module
in flag

I have one main view with pager where I actually using ?page=n (which can't be changed in my case) to navigate on the main view using the Pagerer module without AJAX. Underneath (with AJAX) I got another view with infinite scrolling effect and everything works, when I'm on www.example.com, but on www.example.com?page=1, the infinite scrolling effect scrolls to the second view page. I also see 20-30 from 1 ...

Score: 0
Smooij avatar
Managed file element in custom field module doesn't save target id
in flag

I have been breaking my head on this issue for a few days now. Using Drupal 9.2.x, I am building a custom field module for a client that has multiple fields. I isolated the problem by only including a managed file field for now, because the other fields are not causing this issue.

I defined a managed file element in my Widget class, which extends WidgetBase:

public function formElement(FieldItemListIn ...
Score: 1
Bulk user creation and email notification
do flag

I want to bulk create about 2-300 users with Drush on a Drupal 8 site. I want each of them to receive a welcome email and be forced to set up their own passwords. This can be done trivially with the "Notify user of new account" option through the UI but I cannot seem to make it work with Drush 9.

I can run a script that reads from a CSV and creates the user, then gives them the needed roles, howe ...

Score: 0
tonytheferg avatar
How do I add colorbox-load classes and attributes to links that come from an svg image?
cn flag

I have SVG images that are added to nodes via svg_image_field module. They have internal links in them /load-parts-ajax/{nid}. The path leads to a pop-up page view of content with this path /load-parts-ajax/%. I am attempting open the view in a colorbox. I have this in my implementation in Drupal 7, which works fine. We installled the colorbox_node module, and used the colorbox-node class and this was ...

Score: 5
In a hook, how can I distinguish between web users and JSON:API users?
cn flag

I have a Drupal website that also hosts an Ionic app via JSON:API. I want website users to be redirected on entity insert, so I added a redirect like this:

function MYMODULE_flagging_insert(FlaggingInterface $flagging) {
  $redirect_url = Url::fromRoute(MYCLASS::SECRET_ROUTE)->toString();
  $response = new RedirectResponse($url);
  $response->send();
}

This code will redirect web users as expec ...

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.