Latest Drupal related questions

Score: 0
VVS avatar
How do I migrate Yii2 passwords?
in flag
VVS

I migrated users from Yii2 to Drupal 9, where there are password hashes like $2y$13$nhBZ37OKp27jJBLgRkFlOuL5ac8Bda5n2XIZTjKON5gKPfIcxh61y genereated by Yii2 with \Yii::$app->security->generatePasswordHash("123qweASD")).

I migrated them 1:1.

Migrating users - advanced password examples says:

If the source system was a PHP based application that used crypt() or password_hash(), these hashes shou ...

Score: 2
Baud avatar
How to display translated fields labels of a node view
sa flag

I would like to display a node in NL. This node is not translatable but I would like to have the fields labels translated in NL.

This rendering occurs in a cron job and is used to render an email in the recipient language (ex: NL).

Unfortunately, the following code output the labels in the current language of the page (if I run it outside the cron) or in the default language of the site from within  ...

Score: 0
mullzk avatar
Modern File Manager for upload and organize documents?
ec flag

Being new to Drupal, I still struggle with its File-Management.

I have the following use-case:

  • Authenticated Users from group 'comitee' can upload files (jpg, png, pdf and docx) to the Server, rename then and structure them in subdirectories
  • Authenticated Users from group 'member' can browse those subdirectories and download the Documents.
  • Optional: Editors can reference to those files in CKEdit ...
Score: 1
WebmasterPF avatar
Adding template suggestions for a view with display ID
jp flag

I need to have suggestions for views to create dedicated template. Actually I've this in my .theme:

function starter_d9_2022_theme_suggestions_views_view_alter(array &$suggestions, array $variables) {
  $suggestions[] = 'views_view__' . $variables['view']->id();
}
function starter_d9_2022_theme_suggestions_views_view_unformatted_alter(array &$suggestions, array $variables) {
  $suggestio ...
Score: -1
Lozi avatar
Orders view personalization
cx flag

Apache 2.4.29 + php8.1 + mySQL 5.7.41 Drupal 9.5.3 Commerce 8.x-2.33

Hi all folks ! I'm trying to personalize the orders view with custumer's name, adress, ... To do that i add the "commande" field in the view with "rendered entity" form, but with that i see all the command's history, commentaries ... despite the fact that i create un special "listing" display format for commands and i hide ever ...

Score: 1
Rafael Silva de Morais avatar
Subtotals with group by
ni flag

I have a view which groups content by date and each row has a field with a numeric value (the worked field in the screenshot below). At the end of each group I would like to display the sum total of the 'Worked' field.

Is this possible in Views?

Example:

enter image description here

Score: 0
mbomb007 avatar
Stripe doesn't see API key after TrustedRedirectResponse
nl flag

I have a controller that calls the Stripe API using stripe-php to create a checkout session.

  /**
   * Checkout using Stripe.
   *
   * @param \Symfony\Component\HttpFoundation\Request $request
   *   The request object.
   *
   * @return \Symfony\Component\HttpFoundation\Response
   *   The response.
   */
  public function checkout(Request $request): Response {
    $stripe_settings = $this-> ...
Score: 0
VardeVim avatar
How can I make include the host?
mp flag

We have a form with CKEditor where a user can compose a news item. When set to 'basic HTML' input, the user can upload an image to insert as part of their input.

Later, I need to get this node body for an email. I can get the body field (what the user put in the editor), which will contain html markup.
However, the image url does not include the hostname. Is there a Drupal way to get the node body ma ...

Score: 1
Klemen avatar
Cache two sets of nodes
fr flag

I have a website where I have some blocks that have one content on all nodes, but different content on nodes with certain NID.

Right now, I have condition in block template based on node ID and blocks have route cache context and node id tags and this works perfectly.

However, this makes a new block cache entry for every NID/route, but in fact, there are only two block variants.

How would one optimize  ...

Score: 0
Grouped date filter with multiple selections
cn flag

I have a view with an exposed filter on a date field. It's a grouped filter by year using the module views_year_filter.

All works as long as I don't enable allow multiple selections. When I enable it and set the option - Any - - this option will not be saved. After a re-opening the filter settings, it's unset again.

And then, with allow multiple selections enabled I get the following errors in my view, ...

Score: 0
Viswa avatar
How to redirect custom ajax form to external url with headers
ck flag

When setting the form with ajax handler like this

  public function buildForm(array $form, FormStateInterface $form_state) {
    //...

    $form['actions']['submit'] = array(
      //...
      '#ajax' => [
        'wrapper' => 'custom_form_wrapper',
        'callback' => '::ajaxCallback',
      ],      
    );
  }

function ajaxCallback() {
  $response = new AjaxResponse();
  $url = "www. ...
Score: 0
Tobias Krause avatar
Check in buildForm method of custom form class if the form was submitted
cn flag

I have created a large form with a class extending FormBase. Many of the elements rendered within the form are only necessary for the user to see - there are not so many really relevant fields in the form but all this data gathering and rendering takes time.

When a form is submitted the buildForm() method is called first and after that the submitForm() method. Then the buildForm() method gets call ...

Score: 0
user24957 avatar
How can I set multi-value datafield on node submit?
bs flag

I would like to calculate and set the fourth (points) subfield of datafield on form submit. In the for each loop, the second and third subfield are used to calculate $points. How can I set/save the fourth value?

enter image description here

function handling_points_settings_submit(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
 $duration = 0.6;
 $node = $form_state->getFormObject()->getEntity()->toArra ...
Score: 0
LeJuanChis avatar
How to modify the "href" attribute of some of the links of an html field type?
pa flag

I'm using drupal 9.4.8 and I have a content type called "articles" which has a "body" field (which is a reference to a paragraph) and I'm making an algorithm to check all the articles already loaded and in its body field check when links are there and look if its "href" attribute has a valid code, otherwise replace the content of its "href" attribute with a "#". So far I did it through a query to the D ...

Score: 0
Baud avatar
How to import localized version of a configuration file
sa flag

With drupal, you can import a single config file.

Let say it is a view config file and let say that this view has been translated in french and has produced a locallized config file under the "fr" folder of the config folder (wiews.view.view_name.yml)

How can I import this single config? In other words, how can I import the translations of this view into another site (same UUID)

Score: 0
Scott Hollenbeck avatar
Block Configuration Form Returning Unexpected Value
mx flag

I'm trying to build a block configuration form. Here's my blockForm code:

  public function blockForm($form, FormStateInterface $form_state) {
    $form['resolve_ip_addresses'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Resolve IP Addresses'),
      '#default_value' => $this->configuration['resolve_ip_addresses'],
      '#description' => $this->t('Resolve IP a ...
Score: 0
Giuseppe avatar
Specific CORS on a custom form POST request
br flag

I'm on D 9.3.x

I have a custom form, e.g.

my_module.my_form:
  path: 'custom-form-end-point'
  defaults:
    _title: 'Custom Form'
    _form: 'Drupal\my_module\Form\MyFormController'
  requirements:
    _access: 'TRUE'

This form is POSTED from an Android app inside a self-hosting html page - so from outside the site server and Drupal, e.g.

<form id="myform" action="https://mysite.com/custom-form-end-p ...
Score: 0
Qaiser iqbal avatar
Render OneAll social login block in a .php file?
ml flag

I am using OneAll social login module for social registration and login. The module's login block works well on any page but not on a .php file. I am trying to render the block in a xyz.php file programmatically. When I try to render it via the following code I only gets The heading text of the block without the Facebook and Google's links.

$blockObject = block_load('social_login_widget', 'social_log ...
Score: 0
abe-cedarian avatar
I need help migrating a mulit-value link field from string w/ 2 delimiters
kr flag

I'm trying to migrate a node bundle from one drupal 9 application to another.

My source format is an XML document.

I'm stuck migrating a multi-value link field.

Both the source and destination machine names are field_quicklinks.

The source value is a string with two delimiters like the following.

"https://www.somedomain.org/somewhere/something.pdf*Something Document^https://www.someotherdomain.org/so ...
Score: 1
Andrew Clemens avatar
How to subscribe to a view render event?
pn flag

I'm writing a module that will inject javascript into the page when a view is rendered. The contents of the javascript will depend on the results returned in the view, so ideally I would have access to that. I'm trying to use event subscriptions to do this. I have the getSubscribedEvents function set up but I'm trying to find a view render event to subscribe to. Is there such an event I can use?

 ...
Score: 1
Jimmyb_1991 avatar
CKEditor 5 Right to Left Support
cn flag

The CKEditor 5 docs claim that version 5 comes with Right-to-left editing out the box. While I am sure this is true, I am struggling to get it to work as such in Drupal 10's version.

I have enabled Arabic on my English-by-default site and have enabled the Language toolbar option in for the text format. While editing the Arabic translation of the site (The UI is now RTL) and have my text in the Arabic la ...

Score: -2
Colorbox and complex modals
do flag

Is it possible to make the colorbox popup take more complex content than just an image and a caption?

On a drupal 9 site I have been asked to modify a simple colorbox gallery to include a long/formatted Caption/story and a title in a responsive two-panel pop-up.

Is such a thing even possible or am I better of building something like this from scratch or with something else?

to expand on the format:

 ...
Score: 0
Statistics counter based on user role
do flag

I need to track some basic usage statistics for a subset of my authenticated user roles in Drupal 9.

Is there a way to make the core statistics counter only count node views based on user roles? The three counters it provides are all I need, I just need them to only record certain user roles.

Score: 1
Drupal Learner avatar
Focus Returns to Field With AJAX Callback
gf flag

I am attempting to complete several AJAX commands based on the value of a field in a node/add form. The commands themselves work. However,when a user is filling out the form the cursor (focus) keeps going back to the field that has the callback when another field is clicked regardless of the value of the field.

In this given case we are trying to see if someone is 64.5 years old and change the fo ...

Score: -3
JM John avatar
Advagg Bundler would NOT spit out same size CSS bundles
mz flag

Trying to make sure Advagg bundler spits out two equal size CSS bundles as it makes a massive difference in initial server response time.

For some reason, Advagg will split files into 2 bundles (first one 4kb and second one 36kb).

On Dev server, it works perfectly with same settings. Both identical systems.

I have tried uninstalling/re-installing a few times with no luck.

On production site, it shows 88 g ...

Score: 0
Check if a value has changed
cn flag

Is it possible to check within a constraint validation if a field value has changed?


namespace Drupal\example\Plugin\Validation\Constraint;

use Drupal\Core\Entity\EntityPublishedInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;

/**
 * Validates the OverriddenButChanged constraint.
 */
class OverriddenButChangedValidator extends ConstraintVa ...
Score: 0
Tyrone M. avatar
Set value in a choices.js dropdown after it's been created
gf flag

Using Drupal 9.4 and choices.js 10.2 (design required a highly styled dropdown that I couldn't do with a standard element). The choices dropdown is created by a view.

When I had the plain select item in place, I could use javascript to set an optional default value for one of the two dropdowns. However, with the choices.js dropdown, I haven't found a simple way to make that happen despite scouring the ...

Score: 2
Prizem avatar
What's the point of using Webform Node instead of directly using a Webform's form?
ga flag

What's the point of using Webform Node instead of directly using a Webform's form?

I have tried both. I see that submissions on a node are not exactly the same as submissions on the direct form, so there's a potential for submissions to get split. If I want people to use the node, but someone finds the direct form, then that can be confusing for people needing to review all submissions.

Is it ok to  ...

Score: 1
Menno van den Heuvel avatar
Views UI javascript is broken
cn flag

I discovered today that the Views UI is broken on one my sites. I'm not sure when it broke, because the Views UI is not one of the things I check after updates. I'm currently at 9.5.3.

My Views UI logs the error "Uncaught ReferenceError: assignment to undeclared variable loadjs", and follows up with a bunch of other errors that I assume stem from the first one.

When I disable JS aggregation the issu ...

Score: -1
How to remove author field from the 'advanced' field group on the node edit form
pe flag

I've got several node edit forms that, in most themes, display the 'advanced' group in a sidebar. I have other plans for the sidebar, though, so I don't want that behavior. I edited some twig and css to make the advanced group appear below the main form, but this is still pretty messy. In particular, we often have to adjust the author field, and I'd like it at the top all by its lovely self... not burie ...

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.