Latest Drupal related questions

Score: 0
Zathrus Writer avatar
Create custom field for shipping method
to flag

I'm trying to add a new field called Opening Hours for commerce_shipping_method bundle. I'm having hard time finding examples how to do this and those I tried didn't really work for me. In fact, not even adding a simple numeric field didn't work for me.

I have 2 YML files in a custom module where I define the testing numeric field.

custom_module.field_instance.yml

langcode: en
status: true
dependencies ...
Score: 0
Suba sekar avatar
Paragraph field in view relationship
cn flag

Created a paragraph type with field named "related literature paragraph" as entity reference and inserted this paragraph type to a content type called landing page for a field named body details. Then created views but i am unable to relate the field "related literature paragraph" . I could not able to see paragraph referenced field name or Content referenced field name in relationship.

I could  ...

Score: 0
hobbsie avatar
menu.tree_storage service is missing from my site
in flag

I have upgraded my Drupal 9 site to Drupal 10.1. One of my custom module uses \Drupal::service('menu.tree_storage')->loadByProperties(); which works fine in drupal 9.5.9, but I get the following error message in Drupal 10.1.

You have requested a non-existent service "menu.tree_storage"

When I used drush dcs | grep "tree", the menu.tree_storage is missing from my Drupal 10 site. Yet it is liste ...

Score: 1
nicola avatar
The migration of a list field doesn't work
th flag

In Drupal 10 I have a field of type List (text) configured with key|label that I need to populate with a migration.

My yml file seems not to work, in the 'process' block I tried with:

  process:
    field_select: key
  process:
    field_select/key: key
 process:
    field_select:
      plugin: get
      source: key

Note that the source field names here (key) were defined by the 'fields' config ...

Score: 0
Tobias Krause avatar
Avoid TypeError when route with type hinted parameter in controller is called with wrong parameter type
cn flag

We defined a route under which a visitor of the website can find some information about how to get data related to the currently shown entity:

aw_api.open_data.info:
  path: '/open-data/info/{entity_type}/{entity_id}/{related_entity_type}'
  defaults:
    _controller: 'Drupal\aw_api\Controller\OpenDataInfoController::build'
    _title_callback: 'Drupal\aw_api\Controller\OpenDataInfoController::titl ...
Score: -2
webuser57 avatar
Backup files very different size
in flag

for a Drupal website, backup is done via databack/mysql-backup (https://hub.docker.com/r/databack/mysql-backup) container.
Drupal version: 9.5.10.
The backup is created.
The created backup file is uploaded to AWS, which works objection free.
But, as visible on the picture, the backup files have very different size!

Does anyone have any idea why the backup files have such different size?
enter image description here

Score: 0
monster_energy avatar
Is there a way to create multiple sitemap.xml files using XMLSitemap module, using arbitrary node properties?
mp flag

I am using XMLSitemap module for version 7 https://www.drupal.org/project/xmlsitemap

Out of the box, it lets me create just one sitemap.xml file. With internationalization turned on, it can generate one sitemap.xml file per language.

Is there a way (maybe using hooks?) to generate multiple xml files, based on an arbitrary node field value? For example, product categories - one sitemap.xml file per cat ...

Score: 0
twhitefrd avatar
Populate field value based on external API response
gh flag

My custom Drupal 10 module takes the value of an address field submitted by the user during node creation, sends that to an external API, and then fills a taxonomy term reference field based on the decoded JSON response and logic that matches to the corresponding term. (Might add more fields and potentially APIs in the future).

I have this working but encountered an issue in that because this imp ...

Score: 0
Baud avatar
Is it safe to remove all untranslated strings?
sa flag

I have a site which contains thousand of unused (and not translated) strings.

I would like to remove them to light up my database.

For the records,those strings where created because the original language of the source files has changed and because of some ugly code like t("$variable" bla bla")

My idea is to remove all the untranslated strings (which will contain used string) because the used string ...

Score: 1
Baud avatar
How do I deal with the problem of stale cookies breaking logins on a migrated site?
sa flag

I just finished the migration of a D7 site into D9.

Unfortunately, as I kept the same domain, before the first time I login to the new D9 site, I have to remove my domain's cookies from within my browser. If I don't remove the cookies, I can't login. (I assume there is some kind of conflict between the D7 cookies and the D9 login process)

My idea is to create a form with a submit button which will r ...

Score: 0
Leeroy avatar
Install module with required config that may exist
ca flag

I have a module that have some config in config/install folder, that require config that may already exist in the current config. So I placed those config under config/optional.

But if those config does not exist, they are not installed and the module installation throw an error for unmet dependancies.

What can I do to have a module that have dependancies on config that may exist ?

Thanks.


More inf ...

Score: 0
Glenn avatar
Why can’t I print Webform submission values in an Twig-templated HTML mail?
ph flag

This is further to https://www.drupal.org/project/webform/issues/2946976.

I'm trying to use a Twig template for the HTML email that is sent upon webform submission; I'm using Symfony Mailer for the HTML.

I have the twig template working, by:

  1. Selecting Twig template as the formatter for the email body
  2. Naming my twig file webform-email-message-html--WEBFORM-ID.html.twig and placing it in my theme fo ...
Score: 0
rhy avatar
Parent render cache not clearing on child node update
ni flag
rhy

I have content types Parent and Child. Parent is a referenced entity in Child. My Parent template lists all children with reference to this parent.

After updating the parents referenced in a Child node, the Parent template does not show the change, unless I manually clear all caches. Disabling render cache globally solves the problem. It seems that Parent cache does not invalidate on updating the ...

Score: 1
Glenn avatar
Define key for html email
ph flag

I'm using Symfony Mailer to send HTML emails in my site.

This requires 'module' and 'key' to find my email twig template file.

How do I find or define 'key' for my email handler in my Webform settings?

Score: 1
Email multiple addresses from a composite element in a webform
us flag

I need to email multiple addresses from a composite element in a webform. Using a Computed Twig element with this code:

{% for m in data.member_information %}
{{ m.email }}
{% endfor %}

The email addresses are listed line by line in Results.

[email protected]
[email protected]

I guess that means they're in an array, but I'm not sure. Here's the configuration of the composite element:

id: member_inf ...
Score: 1
Search API autocomplete view mode template
in flag

I got search api autocomplete setup and using the live results feature I was able to set it to use my Search Autocomplete view mode. I am trying to figure out what the twig template name would be. Any ideas? I don't see the twig debug suggestions. Guessing because its coming in via ajax.

Score: 1
Mira chalak avatar
Media library vs entity browser
eg flag

I am creating a brand new multilingual drupal 10 site and I have to choose between Media library and Entity browser for the manage form display of my media reference fields. I have searched all over the web but I can't find a clear comparison between the two. From what I noticed from testing, media library has a better UX/UI comparing to entity browser. However, it doesn't add an "edit" button for the m ...

Score: -3
acey avatar
Why do I get this exception?
mu flag

I'm getting this error constantly and I can't quite figure out what's wrong.

TypeError: strpos(): Argument #1 ($haystack) must be of type string, array given in strpos() (line 126 of core/lib/Drupal/Core/Extension/Dependency.php).
strpos(Array, ':') (Line: 126)
Drupal\Core\Extension\Dependency::createFromString(Array) (Line: 228)
Drupal\Core\Extension\ModuleHandler->buildModuleDependencies(Array) ( ...

Score: 0
Dynamdilshan avatar
Image styles are not created inside the styles directory
in flag

I don't know if this is a Drupal CDN module issue. I have been trying to fix this issue for a few days now but I still have no luck. When I upload an image to my Drupal 9.5 I can see it's been uploaded to one location: public:///styles/large/public/banner/10712751_0.jpeg

I also have some image styles for the same image. I do understand the image styles make the images when someone refers to it, but, in  ...

Score: 0
acey avatar
My custom module shows up on the modules list but I cannot enable it, why?
mu flag

I've written a custom module (custom_data_import) with a .info.yml file and .module files, but the module only shows up in my list of modules and I cannot enable it. Moreover, the .module file seems to act like a plain text file. Can someone please help?

The content of the custom_data_import.info.yml file is the following.

name: 'Custom Data Import'
type: module
description: 'Custom module to import JSON ...
Score: 0
How can I disable the core migrations?
sr flag

After I enabled the Drupal Migrate module in Drupal 10, every time I do a drush ms I get a page of errors about Drupal 7 migrations like the following one.

[error] Could not retrieve source count from d6_filter_format: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'PRODUCTION_content_shared.filter_formats' doesn't exist: SELECT COUNT(*) AS "expression"

Is there a way to disable migratio ...

Score: 0
Form States not working when compressed javascript is enabled
cn flag
blu

I have visible states setup for a 2 fields that correctly work when javascript aggregation is disabled. When I turn JS aggregation on both fields are visible no matter what option I select on the triggering field.

The error I see in the console is:

jQuery.Deferred exception: undefined is not an object (evaluating 'drupalSettings.dialog.buttonClass = 'btn'') 
(anonymous function) — js_fsUR56avHuCdleL ...
Score: 1
Ben Alan avatar
How do I hide the label of disabled field groups?
do flag

In the Manage Display tab, I have disabled fields because they are rendered in the page.html.twig file inside of a region. I don't want the field to display the label.

I can set the label to hidden for the non-disabled fields, but for the disabled ones, when I change the label to "- Hidden -" it simply reverts itself back to "Above"

Here is the field before clicking save:

Label for image before save

Here it is after save:

Score: 0
GeorgeCiesinski avatar
Am I hardening the permissions in settings.php correctly?
mv flag

Last month, I encountered an issue where I could not edit settings.php as it was read-only.

I asked this question and learned how to change the permissions to edit the file, and then harden them again. The result was that vim would warn me a file is read-only until I used chmod a+w settings.php. After this, vim would no longer warn me about this and I could make the changes I need. Finally, I use ...

Score: 0
JohnC95 avatar
Alphabetically sorting by taxonomy name
mc flag

I have a content type with a taxonomy term entity reference tagged to it. I am trying to make a view that lists all nodes of this content type but I want the sorting to be alphabetical based on the taxonomy term tagged rather than by the node title.

It sounds simple in my head. I simply put in the Field of the taxonomy entity reference under "sort" in the view and set it to be ascending order. Bu ...

Score: 0
ice70 avatar
Toolbar and gulp/browsersync: body tag overwritten with comment
cn flag

In Drupal 10, with a gulp/browserSync sync to localhost:3000, I am getting the comments in web/core/modules/toolbar/toolbar.module showing up at the top of my page.

// These are classes that toolbar typically adds to <body>, but this code
// executes before the first paint, when <body> is not yet present. The
// classes are added to <html> so styling immediately reflects the current ...
Score: 0
David Barrett avatar
Populate a 2nd date field min date from a previous date field in webform before submission
jp flag

I have 2 date fields on a webform. The 1st date field has a min date set

first_date:
  '#type': date
  '#title': 'First Date'
  '#date_date_min': 'today + 3 days'
  '#datepicker': true
  '#date_date_format': 'l, F j, Y'

The 2nd date field needs to be populated with a minimum date, reflecting the date entered into the 1st date field so that the user cannot select a date before the date entered into the ...

Score: 0
Tyler avatar
Server went down while uninstalling a module; now I cannot install or uninstall the module
ca flag

I am unable to remove the ECA Core module on my Drupal 10.1 site due to the below error.

Core module for ECA framework.
The following reason prevents ECA Core from being uninstalled: Required by: eca_user

Unfortunately while I was initially removing the ECA User module, my host/server crashed and this is where I am at once everything came back up. I can select the ECA User module to re-enable, how ...

Score: 1
ThankYouNeco avatar
How to find PathAuto state?
cn flag

I am trying to put together a list of content on the site that has the PathAuto setting still checked so it will update when the title of the page is changed. Can't seem to find where this would be stored in the database.

Just wondering if it is possible to find what Pathauto state is set for each entity on my site. I know in previous versions of Drupal there was a database table called pathauto_ ...

Score: -1
mahasri avatar
If conditions in twig to check if field has a value
et flag

I have used this below code to check if the field has a value

{% if content.field_title is not empty %}
    <p>{{ content.field_title }}</p>
{% endif %}

But p tag is rendering even though the field doesn't have a value. Same happening for {% if content.field_title is not null %} as well and {{ dump(content.field_title) }} is not an empty array if the field has no value. So how to che ...

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.