Latest Drupal related questions

Score: 1
Matoeil avatar
How can I add HTML links in e-mails?
za flag
          $content_title = $translated_entity->getTitle();
          $url_alias = \Drupal::service('pathauto.alias_cleaner')
            ->cleanString($content_title);
          $content_link = <<<link
    <a href='/publications/$url_alias'>$url_alias</a>
    link;
          $params['node_title'] = 'Chaire ANMT – Nouvelle Publication : ' . $entity->label() . '';
          $ ...
Score: 0
AppLEaDaY avatar
How can I debug an "access denied" on almost every webform?
br flag

I checked every configuration section that I thought could affect access to webforms. Except for the sample content named Demo: Application (/node/371 in my context), every webform - the URL prefix is /form/ - can be accessed just by an administrator, that is a unprivileged user gets an Access denied answer (You are not authorized to access this page). This is driving me nuts. I cannot tell since wh ...

Score: 0
user3532287 avatar
Report of coupon and users
ro flag

I have users who are partners and users who are clients. When clients submit an order, they use a custom coupon code associated with each partner. (Each partner has a Mycodes field set within their profile.)

Previously, at the end of the month, we would download the sales into an Excel sheet and calculate the commissions of each partner using the partner's coupon codes.

Now I want to do this on the w ...

Score: 1
bimsalrobit avatar
Why does libraries-extend not change part of the styles of the module DropzoneJS?
id flag

I use the DropzoneJS module. To change to change part of the styles written here: /modules/contrib/dropzonejs/css/dropzone.widget.css I use libraries-extend.

In the files of my theme particle I wrote:

particle.info.yml:

libraries-extend:
   dropzonejs/widget:
     - particle/dropzone-custom

particle.libraries.yml:

dropzone-custom:
   version: VERSION
   css:
     theme:
       css/style.css: {}
Score: 0
Andrew Morris avatar
How can I patch a Composer dependency to make the dependency compatible with other dependency versions?
mw flag

I'm trying to update my site from D9 to D10, I've had quite a lot of modules to go through, and for the most part a lot of them have releases which are stable for D10, but roughly 4-5 of them only have the auto-generated patch (which I've referenced in the composer.json file)

Except for some reason composer doesn't seem to acknowledge the local patched version when I'm trying to update Drupal Cor ...

Score: 0
João Soares avatar
error using lando drush site:install --db-url=mysql://drupal10:drupal10@database/drupal10 -y
mg flag

So after I download lando I was going to start to install drupal 10 in this guide :drupal site and in the final step the download of drupal doesnt work it gives me an error when using this lando drush site:install --db-url=mysql://drupal10:drupal10@database/drupal10 -yenter image description here

Score: 3
Geat avatar
Can I use pseudofields in anything other than source?
de flag

If I use pseudofields in the source property for my custom plugin, they are correctly substituted with the computed values. If I use them in another configuration (as per the example), they are treated as literal strings:

 field_myfield:
    -
      plugin: my_custom_plugin
      items:
        -
          title: 'Title 1'
          content: '@computed_field_1'
        -
          title: 'Title 2'
 ...
Score: 1
Onyx avatar
Filter only by existing nodes
cn flag

I am trying to get a view to have only a selective range of referenced content, (somewhat like https://www.seek.co.nz Classification filter) in its exposed filter, but not having any joy so far.

This is the scenario.

Content type of Organisation can have one or more Roles. Each Role has a field; organisation; which refers to the Org it belongs to.

I built a View listing the Roles, and can expose the org ...

Score: 0
Patoshi パトシ avatar
Creating taxonomy terms via REST API using POST: proper formatting of json?
kr flag

On Drupal 9.4 here and I want to create taxonomy terms via the api. Is there a good example of what I need to POST to an API end point?

Score: 1
Patoshi パトシ avatar
How to give ability to create custom NID numbers via API REST post when creating content?
kr flag

I'm using Drupal 9.4 and I tried to pass in a nid value in my POST via the Drupal api. I'm getting the error:

Response: {"message":"Access denied on creating field \u0027nid\u0027."}

My user has admin rights, but how do I give it access to create a custom nid?

Score: 1
tanc avatar
When adding translations in twig, is the source language always English?
in flag

When adding translatable strings in Twig templates, is it assumed that the string is always written in English and then translated to other languages? Even if there is a different 'base' language or only one (non English) language used on the site?

I've been scouring various docs pages and this is the only time I've come across anything stating this explicitly:

UI text is always put into code an ...

Score: 1
Ricardo Castañeda avatar
Schema insert row only if primary key doesn't exist
at flag

I'm doing an exercise where I have a table called visit_counter with fields uid (primary key that stores the user id) and user_visit_count (sum of user's page visits). The purpose of the table is to store the user id and to count the times the user visits the page that loads the controller.

My problem is that my if condition is not working well. I'm trying to insert the row with the uid (primary key,  ...

Score: 0
Glenn avatar
How to alter webform programmatically using hook_ENTITY_TYPE_prepare_form()
ph flag

Using Webform 6.2.0-beta5 on D10.0.9.

I have created a custom webform with a module; this is working perfectly.

Now I need to make several changes to the webform; some values will be calculated within my custom module, used as the default value for fields, and then the fields will be hidden.

With this code I can see the $webform details:

function mymodule_webform_submission_prepare_form(WebformSub ...
Score: 1
Tourist avatar
Display only the first child of a book
cn flag

I have a book "continent". Child are like this : Continent > Country > State >cities > Street

There are several countries, several states, several cities.

When I visit a State, a City or streets, I want to have a block to display the Country (the first child of the book).

What I tried to do in Views: Relationship : Book parent Contextual filters : Node ID with the relationship Book parent F ...

Score: 1
Advanced queue module: How to stop processing queue in cron, when some conditions apply in job event/job preprocessing?
fr flag

I have a custom module handling jobs from the Advanced Queue module. To limit the number of jobs allowed to be processed in one cron run, I have some configuration variables in my custom module. With an event listener my function gets called correctly, when the queue is processed.

How can I fetch the current running process of the queue and stop it?

public static function getSubscribedEvents() {
  $eve ...
Score: 1
Best way getting video url for paragraph on a node with a field video (media core)
bd flag

When I have a paragraph on a node with a field video (media core), is there another good practice to get the URL of the video?

I have this in the twig-file field--paragraph--field-video.html.twig:

file_url(item.content['#media'].field_media_video_file.entity.uri.value)

Or is there a better way in a field--paragraph--* file?

Score: -2
lolhonk avatar
Argument #1 ($callback) must be a valid callback, class Drupal\node\Entity\Node does not have a method "getCurrentUserId"
in flag

I upgraded from Drupal 8.9.20 to Drupal 9.59. All modules seem compatible (upgrade manager). The site is up and running, but if I try to add new content via node/add/article, this error appears.

TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, class Drupal\node\Entity\Node does not have a method "getCurrentUserId" in call_user_func() (line 400 of /html/core/lib/Drupal/Core/ ...

Score: 0
Why is my javascript settings variable empty in Chrome/Edge, but it works in Firefox?
br flag

My javascript file starts like this...

var my_global_var;

(function ($, Drupal, drupalSettings) {
  'use strict';

  Drupal.behaviors.myBehavior= {
    'attach': function attach(context, settings) {

      console.log(settings); // settings is empty in Chrome and Edge, but it works in Firefox.

...
    
})

(jQuery, Drupal, drupalSettings);

I add the settings in my block's build method...

  /**
 ...
Score: 1
Chanel avatar
Unable to reinstall Admin Toolbar in modules directory
mx flag

All my modules are in the web/modules/ directory except for Admin Toolbar which is in web/modules/contrib/. (Why? Long story, legacy site.) Admin Toolbar refuses to update now because of the inconsistency.

I temporarily changed the composer modules directory to web/modules/contrib/ and uninstalled the toolbar flushing the cache all along the way. I then removed the admin_toolbar directory and the ...

Score: 0
witti avatar
Showing parts of ajax-enabled forms in Dialog and using submit buttons in Dialog to change the form?
gr flag

I'd like to achieve the following (d10):

In a form a list of custom drupal plugins will be displayed. Each of those plugins has a settings form array depending on its type that will be merged into the form as part of the list of plugins.

Users can add plugins by clicking an ajax-enabled add-button that shows a dialog popup with buttons for each plugin. This is similar to what paragraphs does when se ...

Score: 1
Владимир Помелов avatar
Theming webform element label template for entity checkboxes field

In the webform, I use the Entity checkboxes component, which allows me to display the options I need using Views, depending on the node to which the webform is linked. But I lack flexibility in terms of setting up the output theme of these fields. In debugging mode, I saw that the markup I needed was inserted in the template "form_element_label.html.twig". How do I override this template for a webform wit ...

Score: 1
Dynamdilshan avatar
How to create a QueueWorker and run it without cron
in flag

Can someone please help me with an example on how to create a QueueWorker class, add items, and run it inside hook_ENTITY_TYPE_presave() or anywhere in a module file?

Basically, what I want is adding an item to the queue and run it soon after a node save, without waiting until the next cron runs.

Score: 0
Eric Sorum avatar
My site is not reading the custom page--user--login.html.twig files I created
gi flag

I am creating custom user (login) pages for my Drupal 9 sites. I have ensured that the files follow the Twig naming conventions and are in the correct folder:

app/web/sites/site-name/themes/our-uikit-theme/templates/user/page--user--login.html.twig

But the site is still reading the Twig file from the core theme directory. This is the path of the login page that the Twig debugging shows in the browse ...

Score: -2
eando avatar
Deleting a File from Website
eg flag

I host my municipality's website (lionsbay.ca) through Drupal. On this website, residents can find council minutes and agendas. Upon request of a resident, she would like her information removed from a past agenda file that was posted in 2021, however, I cannot seem to delete the file through the website. I've tried tracing the file path but I cannot seem to find the direct source of the file's location ...

Score: 3
File can not be copied during migration of media entity
in flag

I'm migrating pictures into Drupal (9) media entities (image). System is using AWS S3 for local storage. I have 2 migrations:

First migrates external images into drupal's files. It copies files from S3 bucket where export is to S3 bucket used as drupal local storage and registers the files.

Second is parsing same data source but creating image media entities from those previously migrated image file ...

Score: 1
sonfd avatar
Search API Solr: How to highlight search term in indexed HTML?
in flag

How can I configure Solr to index a search result view mode, and render that indexed content with the search terms highlighted without highlighting text in attributes?

We are indexing a "Search Result" view mode for every node and then using views to render that indexed content on a search results page. This view mode is very simple (see markup below). The problem is that if a search term appears  ...

Score: 0
Priya Degwekar avatar
Is it possible to not show extra box by default when Allowed number of values is Unlimited in Text (formatted, long, with summary)?
gb flag

I have created a long text formatted field with unlimited allowed number of values. But it is giving one extra box as default.

box

Every time user edits the content the empty box will show. That is so annoying. Second box should be appear only when I click on Add another item

Case1: (first edit) enter image description here

Case2: (second edit) enter image description here

It is creating issue after second edit. Anyone have any idea that How can I make this  ...

Score: 0
How to remove an uploaded file with JSON:API?
cn flag

I have an image field on the User entity that saves to the private filesystem. The field is limited to one image.

I can POST an image file to the field using JSON:API in accordance with this change record.

However, I cannot figure out how to delete a posted file. I don't want to upload a new file to replace it; I want to remove the file that was uploaded from the user. How can I do that?

Score: 0
Kernel test throws errors: field not found, and Base table or view not found:
fi flag

Here's the class I want to test:

class Thing {
  
    public function foo() {
      return \Drupal::entityQuery('node')->condition('body', 'blah')->execute();
    }
  
  }

And the test:

class footest extends \Drupal\KernelTests\KernelTestBase {

  public static $modules = ['node', 'user', 'field'];

 public function testFoo() {
   $thing = new Thing();
   \PHPUnit\Framework\assertEquals($th ...
Score: 0
Custom form, add admin editable instructions from settings area to form
za flag

I have a custom form that is working great. I'd like to add a field "instructions" right under the title, above the first form field. This "instructions" field is editable in the module settings area. I have tried to get this data like:

$config = $this->config('myform.settings');
$instructions = $config->getValue('instructions');

however, it throws an error:

Call to undefined method Drupal\Core\ ...

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.