Latest Drupal related questions

Score: 0
Getting different Public path for admin and anonymous users
cn flag

My site was built using Lightning Drupal distribution.

I had my public path as /sites/default/files. I did change the configuration path to /sites/<my_domain>/files in the middle of the project. From then, when I upload an image to a node it's taking the destination as /sites/<my_domain>/files as expected.

Problem:

I've created a view block to display the node titles and images on the home pa ...

Score: 0
Kevin avatar
Custom block plugin does not show in Layout Builder options
in flag

Newish to Layout Builder - we made a custom block plugin that renders a custom form. When I go to a page with Layout Builder and try to add that block... it is not in the list of blocks.

/**
 * Provides a form block.
 *
 * @Block(
 *   id = "my_block",
 *   admin_label = @Translation("My Block with Form"),
 *   category = @Translation("Custom")
 * )
 */
class MyBlock extends BlockBase implements Co ...
Score: 0
admin/modules takes 40 seconds to load after uninstalling custom module
lb flag

During the development, I made a couple typos in the block which resulted in Drupal seeing the module as being deleted without having been uninstalled first. When I realized what I had done, I put the typo back in place then did a proper uninstall of the module. I then went back, fixed the typo and re-installed the module. From what I can tell, the bad module was uninstalled properly and the good mod ...

Score: 0
Michael Von Bargen avatar
Ckeditor inline images path
fr flag

I am running a Drupal 9 site and I expect my users to upload a lot of files with the ckeditor functionality. All of those files will be stored in a single folder.

I heard that this will cause performance issue once there are a lot of files. To avoid this, I would like to include a timestamp in to the path where to file will be stored, similar to what Drupal does to regular file uploads.

Is there a w ...

Score: 0
Hermann Schwarz avatar
Actions form array overriding to set HTML id attribute
cn flag

I extend the EntityForm class and I try to override a submission button, to set its HTML ID attribute (try #1). Since it doesn't work, I tried to wrap the button in a wrapper <div>. I tried to wrap with two different ways (try #2 and try #3), but they don't work. The only way I can override the submision button is to set '#attributes' to set the HTML attribute class and to add my own CSS class,  ...

Score: 0
Argument 6 passed to Drupal\layout_builder\Plugin\Block\InlineBlock::__construct() must implement interface
cn flag

I was upgrading Drupal 8 to 9. I installed 'Upgrade Status' module and fixed as suggested by it. Now it was time to upgrade to D9. I changed on composer.json.

"drupal/core-composer-scaffold": "^8.9.0",
"drupal/core-recommended": "^8.9.0",

To

"drupal/core-composer-scaffold": "^9.1.0",
"drupal/core-recommended": "^9.1.0",

Then ran following command:

composer update
drush cr
drush updb -y

After runni ...

Score: 0
Interlated avatar
How to see if ajax has been added to a simple node form?
km flag

This very simple #ajax customisation to a node form is not working. How can I tell whether the callback has been added? I want to calculate a field if the first field is changed.

function cbi_currency_form_node_bond_edit_form_alter(&$form, FormStateInterface 
   $form_state, $form_id) {

    $form['field_bond_amt_issued']['#ajax'] = [
    'callback' => 'cbi_currency_convert_usd',
    'event' ...
Score: 0
stckvrw avatar
Hash in menu item url are removed when displaying the menu on a page
gb flag

If a menu item has a submenu and I specify the hash symbol (#) in the Link field of such parent menu item in the admin panel, I receive empty url at the frontend and therefore if click by such link, I follow to the homepage.

Even if I use in my menu--main.html.twig template the code like

{% set menu_item_url = item.url %}
{% if menu_item_url == '' %}
{% set menu_item_url = '#' %}
{% endif %}
<a  ...
Score: 0
Decoupled site as a presentation (display) layer for external microservices?
dk flag

I understand that Drupal 9 out of box is very capable as a decoupled aka headless Drupal serves as a back-end for other apps (the core REST, JSONAPI capability).

However, I am thinking about the reverse way: having Drupal 9 as a pure presentation layer that pulls and displays data from various external micro-service APIs. For example, an external API outputs a product list JSON and a Drupal page  ...

Score: 0
crafter avatar
Migration lookup and no stubbing
jp flag

I have a problem with languages and no stubbing regarding migration_lookup plugin in Drupal 8. I have a different json data, each of them is different languages for example json with de:

data:{ id: 12345, name: 'Product 1 de', id: 123456, name: 'Product 2 de'}

json with en

data:{ id: 12345, name: 'Product 1 en'} 

of course this json is only example not validate.

I have a 2 migration yaml file called: m ...

Score: 1
Create a user map with a results tables below it
gb flag

I've been searching around for the past couple months, watched a lot of YouTube videos, and read a lot of tutorials, and I've made a lot of progress with an alumni directory our team is creating. But, the one challenge I haven't been able to overcome is how I might put a map of where users are located on the same page as a results table with information about them.

To give more details:

  1. We are using Pro ...
Score: 2
Mandock D. avatar
How can I bulk delete users?
kr flag

My site got hacked and I had an online service clean it out. However, it now has over 150,000 user accounts, the bulk of which have no role assignment. How do I delete these accounts and their content?

PS: Drush solutions are appreciated and welcome, but for now I would prefer non-Drush answers.

I tried suggestion 1 at How to delete 'blocked' users in bulk? but both options are time consuming and the VBO ...

Score: 1
berliner avatar
Is it a valid approach to have a different CSP based on login state and browser?
bd flag

I'm currently working on improving the security of a Drupal 8 site by implementing a Content Security Policy. As this is still new to me, I would like to get some input on my strategy.

Relevant base setup

  • Drupal 8, with a custom patch that makes ckeditor.js pass on nonces when loading it's plugins, CKEditor only being used by logged in users
  • Security Kit, patched to provide an alter hook for the ...
Score: 0
mr.Thi avatar
Entity field condition with "Not Contain" target_id for field multiple values
in flag

Entity E have a field reference to Taxonomy T with multi value.

E.field_term.value = [
  ['target_id' => 1],
  ['target_id' => 4],
  ['target_id' => 7],
  ['target_id' => 9],
];

How to query the list of Entity E which not contain Term T (term_Id = 7). I expect some thing like this:

$query = $this->entityTypeManager->getStorage('node')->getQuery();
$query->condition('field_ ...
Score: 0
J. Scott Elblein avatar
Best upgrade path?
jp flag

One of my Drupal sites has been languishing on Drupal 5.

It has a lot of content, so I can't just start from scratch. I'm considering to finally upgrade it to Drupal 9.

What would be the best and easiest path to getting all caught up?

Should I make a clone of my most recent 5 on a development machine, then install each of the next version using its upgrade method?

Can I just install Drupal 9 over my ancie ...

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.