Latest Drupal related questions

Score: 0
When I try to migrate, the wrong migration plugins are used
cn flag

I'm trying to migrate a Drupal 6 site to Drupal 9. The problem is that when I try to run the migration I get a lot of errors as if Drupal try to use the Drupal 7 migration plugins instead of the Drupal 6 migration plugins.

I get these messages.

Field discovery failed for Drupal core version 7.

TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given en in_array() (líne 106 of ...

Score: 1
sjhuskey avatar
View only your own comments, no one else's?
cn flag

I have a client who would like users to be able to comment on content without being able to see any other users' comments. This is for a review system where users shouldn't feel influenced by the views of other users. I'm using Drupal 9.3.14 and a subtheme of Radix.

I have tried adding this to my theme's comment.html.twig:

{% if author_id == user.id %}
    {{ content }}
{% endif %}

That works for a wh ...

Score: 0
Status messages don't show
us flag

I have a controller that manages a password reset form submit. Everything works fine, except for setting messages. I've tried to alter the message in the .module file too with no luck. It worked on Drupal 8, but after migrating to drupal 9 it doesn't work anymore. Here is the code:

<?php

namespace Drupal\custom_form_save\Controller;

use Symfony\Component\HttpFoundation\Response;
use \Drupal\Co ...
Score: 0
How to remove a sort in hook_views_query_alter
cn flag

I've got a search API search view that has two sorts on it. relevance and then published date. This means that when I do a text search the relevancy score handles the sorting, but when there is no search text, the results are ordered by date. Recently I added some boosting, which has caused that fallback to stop working.

I'm trying to figure out how to remove that first sort (relevance) when t ...

Score: -1
jons avatar
Status: 500 Internal Server Error
br flag

I run /path/to/drush/drush status from the shell just fine, but if I run it from a script called from cron I get this error.

Status: 500 Internal Server Error
Content-type: text/html; charset=UTF-8

This implies that PHP CGI is being called rather than CLI. It looks like an environment issue. How do I resolve it?

Running Drush with --debug gives the same result (no extra output from Drush). The c ...

Score: 0
hook_form_alter() to add placeholder to a text field via custom module
vn flag

It should be very straightforward and yet, I can't identify the reason why this doesn't add a placeholder to a field in a form:

function posts_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if ($form_id == "node_post_form" || $form_id == "node_post_edit_form") {
    $form['field_post_subject']['#attributes']['placeholder'] = t("blah");
    dpm($form['field_post_subject']);
  } ...
Score: 0
chalo avatar
I lose template suggestions when an ajax event is called
de flag

I'm generating theme suggestions based on the formdazzle module, I made my own variant because I needed another level of granularity of theme names and it works fine.

Well, in the alter hook I have the key #pre_render and the method to generate de suggestions:

Example

$form['#formdazzle'] = ['form_id' => $form_id];

 // Add our pre-render function to the end of the list.
 if (!isset($form['#pr ...
Score: 0
How do I get coupons usage in a view
cn flag

There is no field for the number of times the coupon was used in Add fields when creating a new view. while other related fields such as Usage limit are available, according to database check:

  1. The fields that can be displayed in the view are all in the commerce_promotion_coupon table. Therefore, there is no field in which to store the sum of the uses of the coupon.
  2. The number of used coupons is the sum  ...
Score: 3
Free Radical avatar
How to get the field name in a validation handler?
kz flag

I have a custom class TextWidget extends WidgetBase

Inside it I have a custom validation handler that looks like this:

public function validate($element, FormStateInterface $form_state) {
  $value = $element['#value'];
  $label = 'This field'; // What method is there to get the human facing field name?
  if (strlen($value) === 0) {
    $form_state->setError($element, $this->t('@label cannot b ...
Score: 1
How do I upcast route parameters for entity_revision?
pl flag

My custom entity is revisionable. I can see revisions, but my revision revert form doesn't work. The route for the form is definited in msul_rovi_games.routing.yml.

entity.rovi_game.revision_revert_confirm:
  path: '/rovi_game/{rovi_game}/revisions/{rovi_game_revision}/revert'
  defaults:
    _title: 'Revert to an earlier revision'
    _form: '\Drupal\msul_rovi_games\Form\RoviGameRevisionRevertForm' ...
Score: 0
Nivothanan Kannan avatar
Create drupal 9 platform in Aegir
in flag

I need to create a new platofrm for Drupal 9 in Aegir.

I have created a makefile in /var/aegir/platform/makefiles/d9.make.

api = 2
core = 9.x
projects[] = "drupal"

I get the No release history available for drupal 9.x. error. It seems there is a release from https://updates.drupal.org/release-history/drupal/8.x but not from https://updates.drupal.org/release-history/drupal/9.x.

Score: 0
Yurii Kovalchuk avatar
Redirects from https to http
cn flag

I want all of my url to end with slash. But I'm facing a trouble where i have a redirect cycle.

For example: https://mysite.com/blog -> http://mysite.com/blog/ -> https://mysite.com/blog/

So there is an unnecessary redirect from https protocol to http. At first i thought that it was gatsby-plugin-force-traling-slashes, website is built with Drupal9 + Gatsby. I removed this plugin, but redirects kept ...

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.