Latest Drupal related questions

Score: 1
liquidcms avatar
How to make a custom entity fieldable?
us flag

This has been asked here before; but question is closed and the few replies do not provide sufficient information.

I am trying to use a contrib module (sitewide_alert) which provides its own custom entity. I am trying to figure out how to patch this module to make it fieldable (and how to do this in general).

In other posts I have seen suggestions to add the follinwg to the ContentEntityType annotat ...

Score: 0
How to keep similar custom services from conflicting?
in flag

I have two modules, each of which is defining a normalizer service

module_one.services.yml

services:
  module_one.normalizer.node_entity:
    class: Drupal\module_one\Normalizer\ModuleOneEntityNormalizer
    arguments: ['@entity_type.manager']
    tags:
      - { name: normalizer, priority: 10 }

module_two.services.yml

services:
  module_two.normalizer.node_entity:
    class: Drupal\module_two\Norma ...
Score: -3
Steffen  avatar
How to fill a form field of type fieldset with values from an array
cn flag

How can I fill a formfield type fieldset with more than one markup value from an array?

foreach ($drugis_postgis_connection->tableNames() as $table) {
    $form['tables'] = [
      '#type' => 'fieldset',
      '#title' => $this->t('Tables'),
      '#markup' => $table, 
      '#collapsible' => TRUE, // Added
      '#collapsed' => FALSE,  // Added
  ];

I don't need more fields i wan ...

Score: 1
Perform an action after each step in a multi-step Webform
in flag

I'm trying to figure out how to grab data from the previous step of a multi-step webform after a user progresses and I'm coming up blank.

Is there a particular hook that gets fired whenever a users progresses forward in a multi-step form or do I need to add a custom submit handler?

Thank you!

Score: 0
YusufFidan avatar
REST API calls are always cached
cn flag

In Drupal 9.2.6 I have a caching issue.

The code I am using is the following.

$returnValues = [
  'value' => 'test',
  'time' => time(),
];

$response = new ResourceResponse($returnValues, 200, []);
$disable_cache = new CacheableMetadata();
$disable_cache->setCacheMaxAge(0);
$response->addCacheableDependency($disable_cache);
return $response;

This leads to this error.

TypeError: Argum ...

Score: 0
Accessing menu protected data
pt flag

How can the protected data of a menu object, pictured below, be accessed ?

enter image description here

using $menu->id() works and returns the menu ID. But neighter $menu->values nor $menu->get('values') work.

Score: 0
emma avatar
Positioning no results behavior in sort order
ro flag

I have a view which uses the Pivot table format with a first_contact field that contains a year (date format: custom, custom date format: Y), and which is the pivot column of the table.

I want to sort the values of this column according to the year (descending). Additionally, I want to have a No results behavior for the first_contact field saying something like no entry here. This No results behavi ...

Score: 2
Baud avatar
Translation of a multilingual site into English
sa flag

Note: This question is only focused on strings inside source files (PHP files).

When you are creating a Drupal site in a non English country (let say France), you will create all your PHP files with French strings inside.

After that, you can translate this site, let say in Dutch. You will extract PO files, send them into translation an re-import them.

Until this point, everything is fine.

Now, your client ...

Score: 0
How can I filter the path aliases by node id?
kr flag

On this page admin/config/search/path, we can only filter the results by URL alias.

I want to filter the results by node id as well?

How can I do that?

It is not possible with form alter. As the original form submit is redirecting to the entity.path_alias.collection route with the url alias filter only.

Is there any way, I can filter them by node id?

Score: 1
Joost avatar
Add custom font to mpdf while using PDF using mPDF module
jp flag

I made a custom module to create a PDF from a views page. This module depends on PDF using mPDF. I'm now trying to add a custom Google font. This should be the default font when generating a pdf. But I can't find out what I should do to have a custom font used in the PDF.

The mPDF documentation gives me an example of what I should do to load the custom font. I tried adding this in a custom functi ...

Score: 0
How can I allow users to change their email addresses without a password with JSON:API?
cn flag

I have an Ionic React app and I want to allow users to change their email addresses.

However, when I try to change the email address in a PATCH request, I get the following error:

{
   "jsonapi":{
      "version":"1.0",
      "meta":{
         "links":{
            "self":{
               "href":"http:\/\/jsonapi.org\/format\/1.0\/"
            }
         }
      }
   },
   "errors":[
      {
      ...
Score: -1
Nasser Karimi avatar
admin/reports/updates page not found
ye flag

On a Drupal 8 project, the admin/reports/updates is not accessible. It just returns a 404 error without any issue.

Score: 1
Kartagis avatar
How can I fix this query error with drush sql-sync?
lu flag

I crafted my drush/sites/self.site.yml like below* and verified that drush rsync @prod:%files @self:%files worked. However, drush sql-sync @prod @self results in the following error:

  The command "/usr/local/bin/drush sql-query --strict=0 --file=/tmp/termitral_db_20211011_110905.sql.gz --file-delete --uri=drupal --root=/var/www/drupalvm/drupal/web" failed.

  Exit Code: 1(General error)

  Working dir ...
Score: 0
Menu item extras field in page.html.twig
cn flag

I need a background image per menu item. For this I'm using menu_item_extras. I added an image field to menu items. This field I'd like to use in page.html.twig.

How can I use this field in this template?

Score: 0
Martin Fuggle avatar
How is the theme folder to use decided?
fr flag

Under /sites/all/themes there are two folders called atlas and atlas.backup. Drupal 7 is pointing to atlas.backup and I don't understand how Drupal knows which theme folder to use.

I want Drupal to use the atlas folder, rather than the atlas.backup one.

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.