Latest Drupal related questions

Score: 4
sailormoon avatar
How to prevent a node from being deleted while performing a delete operation?
cn flag

I want to prevent a node from being deleted while a delete operation is performed on it. For example in administration panel if user clicks "Delete" on the node, the node shouldn't be deleted if he is not an administrator. Permissions and user roles are not a problem for me, the problem is "stopping" delete operation.

I found hook_entity_predelete(), which is perfect, it runs exactly just before deletin ...

Score: 1
Image with itok "cannot be displayed because it contains errors"
jp flag

We are uploading images to our site (Drupal 9.2.6). In the source of the page, the images are added to with an ?itok=. The browser cannot view the image and when I put it directly into the address bar it states "cannot be displayed because it contains errors".

The image is correctly created and in the file directory. After removing the query param from the url, the image works fine.

Any thoughts on  ...

Score: 1
Geat avatar
Injecting a NEW instance of a service into another service class
de flag

I have a service (for sending error alerts) which is used by multiple other services.

The alert service is injected into those classes via the relevant services.yml files and through their constructors.

However, both classes share the same instance of the service (something I actually didn't realise until now). If I set a property from one class, it's available for the other class to use later.

In some ...

Score: 0
How to manually deploy on a shared hosting?
uy flag

In my shared hosting: no git, no composer, no root folder settings. Only the folder "public_html". And my Drupal files: vendor, web, composer.json, composer.lock.

How should I put it all in public folder? What should I change? In settings.php I've already written my new db settings, but this is not enough.

Score: -3
Tak avatar
Change workflow state with particular payment method
jp flag
Tak

Right now i have a payment method called "Transferência Bancária" and I need it to change to the workflow state "Awaiting Transferencia" automatically when that payment method is selected.

Is it possible to do programmatically?

I'm stuck at: $order = $event->getEntity(); if(($order->getPaymentGateway()) == ('transferencia')) { $order->set('state', 'aguardando_transferencia'); }

on my /mo ...

Score: 1
Restrict users from creating administrators?
fi flag

I want to give some users the ability to add and edit other users, but I don't want them to be able to add administrators (or for them to be able to give themselves or other users the "administrator" role).

This seems like something that would be commonly required, but I don't see any way to do it OOB, or any existing module.

Have I missed something or does this need doing as a custom module? If so, ...

Score: 0
zapico avatar
View with translation not working as expected
cn flag

I have a view that filters content (films) by category and it works as expected.

I've added a new language to the site and some categories are not applied in both languages to the same content, but the view returns all the films that have that category in the main language, even if it doesn't have that category in current language.

For example, if I have a film with these categories in English:

  • S ...
Score: -1
Using Authentication API module
mx flag

I'm trying to use the User Authentication API module. My goal is to add some post-processing after successful Drupal 7 login that posts JSON to an external web service. This would be work very similar to the Webform Remote Post module, but for the login page.

My problem is that even though the module is installed fine, and things look good on the page which displays detected plugins, nothing seems  ...

Score: 2
Елин Й. avatar
How to return an XLS file to download on form submit
je flag

I am trying to create an XLS file and send it to the browser on a form submit but I cannot figure out how to do it. I am using XLS Serialization module but I'm open to all other suggestions. With this module I successfully created some views with XLS Export feature. But now I have a form and the excel file should be created on form submit depending on the submitted data.

I created the following c ...

Score: 1
Conditionally display headers on web page in page.html.twig
mx flag

We have a header which contains a secondary menu on top bar, search, main menu and logo in page.html.twig.

We would like to implement a new header with quite a few changes and so would like to add a bool field or some field, somewhere for example all Content Types. So the user, adds a page sees this field and if checked to display new header. Is this possible?

Score: 0
Jeirod avatar
How to retrieve #tree values inside a form?
cn flag

I am new at Drupal 8 and I am creating a module that has a #tree form. I chose #tree form to create multiple forms which has the same textfields and button.

I came across one document in drupal about #tree.
https://www.drupal.org/docs/7/api/form-api/tree-and-parents
I have made a researched about it and can't find any documentation, post or blog on how to get a specific value from #tree.

I have implemente ...

Score: -1
ventura avatar
How do I list all users in a view that have created a node with certain taxonomy terms?
cn flag

The goal is to create a view to list users on a page with url /search/[category]/[topic]/[location] where "category" "topic" and "location" are taxonomy fields in nodes that users can create.

I want to list all users that have a node were the "search" queries apply.

/search/all/all/all should list all users

/search/all/topic1/all should list all users that created at least one node with topic "topic1 ...

Score: 0
Mira chalak avatar
Varnish and custom blocks
eg flag

I want to configure varnish on my drupal 8 multilingual website and I have a block that appears on a page whose path is /my-test . So in french the url would be like this : /fr/my-test whereas in english /my-test . In this block, I simply use:

$lang = \Drupal::languageManager()->getCurrentLanguage()->getId(); to detect the language and then display news depending on this language. so when the ur ...

Score: 0
ShabbyAbby avatar
Import multiple images with sub_process and image_import
to flag

I have some nodes with multiple images I want to import. How can I combine sub_process plugin with image_import?

"field_image":[
    {"src":"https://example.com/image1.png","alt":"Image 1","title":"Image one."}, 
    {"src":"https://example.com/image2.png","alt":"Image 2","title":"Image two"}
]

What can I do to loop throw the array of images and import them later.

Here is example of my YML migratio ...

Score: 1
Jean da Silva avatar
Render responsive image inside form fields programmatically
cn flag

I am trying to figure out how to render a responsive image programmatically inside a form field. I am doing maintenance in a code on my current job, and sometimes there are form fields using the '#markup' property. Now I need to change all images to be responsive.

The code example:

$form['markup1'] = [
     '#markup' => '<div class="rating_reminder"><img src="'.file_create_url($order->c ...

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.